|
|
@ -21,7 +21,7 @@ OSSL_HTTP_REQ_CTX_set_max_response_length |
|
|
|
typedef struct ossl_http_req_ctx_st OSSL_HTTP_REQ_CTX; |
|
|
|
|
|
|
|
OSSL_HTTP_REQ_CTX *OSSL_HTTP_REQ_CTX_new(BIO *wbio, BIO *rbio, |
|
|
|
int method_GET, int maxline, |
|
|
|
int method_POST, int maxline, |
|
|
|
unsigned long max_resp_len, |
|
|
|
int timeout, |
|
|
|
const char *expected_content_type, |
|
|
@ -53,17 +53,19 @@ This file documents low-level HTTP functions rarely used directly. High-level |
|
|
|
HTTP client functions like L<OSSL_HTTP_get(3)> and L<OSSL_HTTP_transfer(3)> |
|
|
|
should be preferred. |
|
|
|
|
|
|
|
OSSL_HTTP_REQ_CTX_new() allocates a new HTTP request context structure, which |
|
|
|
gets populated with the B<BIO> to send the request to (I<wbio>), the B<BIO> to |
|
|
|
read the response from (I<rbio>, which may be the same as I<wbio>), the |
|
|
|
request method (I<method_GET>, which may be 1 to indicate that the C<GET> |
|
|
|
method is to be used, or 0 to indicate that the C<POST> method is to be used), |
|
|
|
the maximum expected response header length (I<max_resp_len>, where any zero |
|
|
|
or less indicates the default of 4KiB), a response timeout measure in seconds |
|
|
|
(I<timeout>, where 0 indicates no timeout, i.e., waiting indefinitely), the |
|
|
|
expected MIME content type of the response (I<expected_content_type>, which |
|
|
|
may be NULL for no expectation), and a flag indicating that the response is |
|
|
|
expected to be a DER encoded ASN.1 structure (I<expect_asn1>). |
|
|
|
OSSL_HTTP_REQ_CTX_new() allocates a new HTTP request context structure, |
|
|
|
which gets populated with the B<BIO> to send the request to (I<wbio>), |
|
|
|
the B<BIO> to read the response from (I<rbio>, which may be equal to I<wbio>), |
|
|
|
the request method (I<method_POST>, which may be 1 to indicate that the C<POST> |
|
|
|
method is to be used, or 0 to indicate that the C<GET> method is to be used), |
|
|
|
the maximum expected response header length (I<max_resp_len>, |
|
|
|
where any zero or less indicates the default of 4KiB), |
|
|
|
a response timeout measure in seconds (I<timeout>, |
|
|
|
where 0 indicates no timeout, i.e., waiting indefinitely), |
|
|
|
the expected MIME content type of the response (I<expected_content_type>, |
|
|
|
which may be NULL for no expectation), |
|
|
|
and a flag indicating that the response is expected to be |
|
|
|
a DER encoded ASN.1 structure (I<expect_asn1>). |
|
|
|
The allocated context structure is also populated with an internal allocated |
|
|
|
memory B<BIO>, which collects the HTTP request and additional headers as text. |
|
|
|
The returned context should only be used for a single HTTP request/response. |
|
|
@ -73,8 +75,8 @@ The I<wbio> and I<rbio> are not free'd and it is up to the application |
|
|
|
to do so. |
|
|
|
|
|
|
|
OSSL_HTTP_REQ_CTX_set_request_line() adds the HTTP request line to the context. |
|
|
|
The request command itself becomes C<GET> or C<POST> depending on the value |
|
|
|
of I<method_GET> in the OSSL_HTTP_REQ_CTX_new() call. I<server> and I<port> |
|
|
|
The request method itself becomes C<GET> or C<POST> depending on the value |
|
|
|
of I<method_POST> in the OSSL_HTTP_REQ_CTX_new() call. I<server> and I<port> |
|
|
|
may be set to indicate a proxy server and port that the request should go |
|
|
|
through, otherwise they should be left NULL. I<path> is the HTTP request path; |
|
|
|
if left NULL, C</> is used. |
|
|
@ -90,8 +92,8 @@ encoding of I<req>, using the ASN.1 template I<it> to do the encoding. The |
|
|
|
HTTP header C<Content-Length> is automatically filled out, and if |
|
|
|
I<content_type> isn't NULL, the HTTP header C<Content-Type> is also added with |
|
|
|
its content as value. All of this ends up in the internal memory B<BIO>. |
|
|
|
This requires that the request type be C<POST>, i.e. that I<method_GET> is 0 |
|
|
|
in the OSSL_HTTP_REQ_CTX_new() call. |
|
|
|
This requires that the request type be C<POST>, |
|
|
|
i.e., that I<method_POST> is 1 in the OSSL_HTTP_REQ_CTX_new() call. |
|
|
|
|
|
|
|
OSSL_HTTP_REQ_CTX_nbio() attempts the exchange of request and response via HTTP, |
|
|
|
using the I<rbio> and I<wbio> that were given in the OSSL_HTTP_REQ_CTX_new() |
|
|
@ -138,7 +140,7 @@ Adding extra headers with OSSL_HTTP_REQ_CTX_add1_header(). This is optional. |
|
|
|
=item 3. |
|
|
|
|
|
|
|
Add C<POST> data with OSSL_HTTP_REQ_CTX_i2d(). This may only be done if |
|
|
|
I<method_GET> was 0 in the OSSL_HTTP_REQ_CTX_new() call, and must be done |
|
|
|
I<method_POST> was 1 in the OSSL_HTTP_REQ_CTX_new() call, and must be done |
|
|
|
exactly once in that case. |
|
|
|
|
|
|
|
=back |
|
|
|