Add HTTP POST support to the HTTP library
Having POST support in the HTTP library of VLC would be very useful for example to expose it with bindings to Lua scripts.
Among other things I need this to fix #25397 and it would be useful for VLSub too, which currently has a not so good POST
implementation in Lua using the socket API (vlc.net.connect_tcp
).
Currently the HTTP library already supports a chunked
transfer-encoded payload when using 100-continue
but nothing else.
(Without 100-continue it can never proceed to create the request as it waits for a reply by the server, which it never gets.)
@Courmisch What do you think would be the best approach to add support for a request payload? One approach I thought about
was to add a new API for vlc_http_msg
:
/**
* Attaches payload data.
*
* Attaches initial payload data to the message that is sent after the
* headers. A Content-Length header with the payload length will be
* added to the request headers.
*
* @note This function takes ownership of the passed data block(s).
*/
void vlc_http_msg_set_payload(struct vlc_http_msg *, block_t *b);
This could add the block to the vlc_http_msg
which then could be used in vlc_http_msg_format()
to add the payload the to the request. The problem with that approach is that I have no idea how it could work for HTTP/2 and that the logging would need to be adapted, as currently it just logs the whole payload that is sent in vlc_h1_stream_open()
and we definitely don't want to log some possible binary data.
A different approach would be to add a flag to indicate if the server is expected to reply right away to the request or not, so that vlc_http_request()
would not forever wait on vlc_http_msg_get_initial()
when not using 100-continue
, and then just send the request payload with vlc_http_msg_write()
(not sure if that would result in the right outcome for HTTP/2 requests).
Some feedback on how to tackle this task would be much appreciated.