OSSL_HTTP_transfer

Open (or reuse), send one HTTP request, receive the response, and optionally keep the connection.

Synopsis

Declared in <openssl/http.h>

BIO*
OSSL_HTTP_transfer(
    OSSL_HTTP_REQ_CTX** prctx,
    char const* server,
    char const* port,
    char const* path,
    int use_ssl,
    char const* proxy,
    char const* no_proxy,
    BIO* bio,
    BIO* rbio,
    OSSL_HTTP_bio_cb_t bio_update_fn,
    void* arg,
    int buf_size,
    stack_st_CONF_VALUE const* headers,
    char const* content_type,
    BIO* req,
    char const* expected_content_type,
    int expect_asn1,
    size_t max_resp_len,
    int timeout,
    int keep_alive);

Return Value

Response-body BIO owned by the caller (free with BIO_free*), or NULL on failure.

Parameters

NameDescription
prctxOptional address of an OSSL_HTTP_REQ_CTX*; reuses *prctx when non-NULL, else opens; may be set to NULL when closed.
serverHostname or address to contact when opening a new connection.
portService port, or NULL for the default (80/443).
pathRequest path (or absolute URI for a proxy).
use_sslNonzero to use HTTPS (requires bio_update_fn when opening via sockets).
proxyOptional HTTP(S) proxy, or NULL to consult environment defaults.
no_proxyOptional comma/whitespace host exclusion list, or NULL for environment defaults.
bioOptional write BIO; NULL builds an internal connect BIO from server/port.
rbioOptional read BIO used with bio when both are non-NULL (no auto-connect).
bio_update_fnOptional connect/disconnect BIO callback (required for TLS when bio is NULL).
argCallback argument for bio_update_fn (not consumed).
buf_sizeMax header line length / read chunk; <= 0 uses the default.
headersOptional additional request headers, or NULL.
content_typeContent-Type for req, or NULL.
reqOptional request-body BIO, or NULL for a GET-style exchange.
expected_content_typeExpected response Content-Type, or NULL.
expect_asn1Nonzero if the response body should be treated as ASN.1 DER.
max_resp_lenMaximum accepted response length in bytes.
timeoutSoft overall timeout in seconds for this exchange.
keep_aliveKeep-alive preference (0/1/2 as for OSSL_HTTP_set1_request()).