You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
Perl 5's LWP::UserAgent has an add_handler()/remove_handler() methods that allow you to specify a sub-routine that will be run (with the request or response object as arguments,) at various phases of the HTTP conversation, thus allowing the user code to respond in a different way to the core code or to alter the request or response in a specific way depending on the circumstances.
A very specific use case for this is the way that redirects are handled, currently we simply build a new request based on the original one with the new location and so forth and then re-request that, however in https://github.com/jonathanstowe/WebService-Soundcloud the "download" will require a redirect to Amazon cloud storage which gets immensely confused by all the headers that have been added for the soundcloud authorization and stuff, so ideally there would be a "redirect request" handler that got control of the new request before it is made to remove all the inappropriate headers.
Other places this would be useful would be in responses suggesting authorisation is required, (a handler could find the auhorisation tokens and make a new request,) or in handling specific response codes in a certain way transparently.
Internally this may also enable us to make the code even more modular (i.e. there are default phase handlers,) and flexible.
I haven't any firm plans for the actual implementation of this as yet but welcome any and all input :)
The text was updated successfully, but these errors were encountered:
Hi,
Perl 5's LWP::UserAgent has an add_handler()/remove_handler() methods that allow you to specify a sub-routine that will be run (with the request or response object as arguments,) at various phases of the HTTP conversation, thus allowing the user code to respond in a different way to the core code or to alter the request or response in a specific way depending on the circumstances.
A very specific use case for this is the way that redirects are handled, currently we simply build a new request based on the original one with the new location and so forth and then re-request that, however in https://github.com/jonathanstowe/WebService-Soundcloud the "download" will require a redirect to Amazon cloud storage which gets immensely confused by all the headers that have been added for the soundcloud authorization and stuff, so ideally there would be a "redirect request" handler that got control of the new request before it is made to remove all the inappropriate headers.
Other places this would be useful would be in responses suggesting authorisation is required, (a handler could find the auhorisation tokens and make a new request,) or in handling specific response codes in a certain way transparently.
Internally this may also enable us to make the code even more modular (i.e. there are default phase handlers,) and flexible.
I haven't any firm plans for the actual implementation of this as yet but welcome any and all input :)
The text was updated successfully, but these errors were encountered: