librelist archives

« back to archive

RFE: POST protocol handlers

RFE: POST protocol handlers

Phil Hudson
2015-04-10 @ 10:37
Currently, `set_protocol_handler' can take a string argument, an URL
locating the protocol handler web service, into which the activated
protocol-URI is interpolated by replacing a "%s" escape. I would like to
have the option to specify that the request be sent using the POST
method rather than GET, and with the `Accept:' and `Content-Type:'
headers configurable -- in my use case, as 'application/json'.

I don't see a way to do this at the moment, so assuming I'm correct in
thinking that POST is currently unsupported, I suggest adding optional
third, fourth and fifth parameters to `set_protocol_handler':

Parameter 3: a string, the HTTP method.

Parameter 4: an associative array of HTTP header keys and values.

Parameter 5: the HTTP request's body content template, either an
interpolation string containing the same "%s" escape to be replaced by
the activated protocol-URI as currently happens for the second argument,
or a function taking one argument, the activated protocol-URI, and
returning the request's body content as a string.

In the case of POST, the second argument to `set_protocol_handler', the
web service URL, must *not* contain the "%s" escape for interpolation;
this will need to be added to the documentation.

Phil Hudson         
@UWascalWabbit                 PGP/GnuPG ID: 0x887DCA63