Motivation
In order to achieve
SingleSignOnForINCLUDE in the form of plugin, we need to have an API to register a hook to customize all HTTP requests to external resources.
Description and Documentation
Proposed interface:
registerExternalHTTPHandler( \&fn );
where
\&fn is invoked whenever objects of
LWP::UserAgent and
HTTP::Request are set up in
TWiki::Net.
The
registerExternalHTTPHandler should only be invoked from inside
initPlugin.
The handler callback (
\&fn) is expected to be written as below:
sub handleExternalHTTPRequest {
my ($session, $url) = @_;
my ($headers, $params) = ([], {});
# set up $headers and $params
return ($headers, $params);
}
where the returned
$headers and
$params are added to the HTTP requests for the
$url, invoked from
%INCLUDE{...}%
or
getExternalResource()
.
The semantics of the return values are identical to the optional arguments (
$headers, $params) for
getExternalResource (discussed here:
AddLWPParametersToGetExternalResource).
Examples
registerExternalHTTPHandler( \&handleExternalHTTPRequest );
Impact
Implementation
--
Contributors: MahiroAndo - 2012-10-24
Discussion
Sound spec!
--
PeterThoeny - 2012-10-24
Accepted by
JerusalemReleaseMeeting2012x10x26
--
PeterThoeny - 2012-10-26