File indexing completed on 2026-04-01 08:26:56
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef OPENSSL_HTTP_H
0012 # define OPENSSL_HTTP_H
0013 # pragma once
0014
0015 # include <openssl/opensslconf.h>
0016
0017 # include <openssl/bio.h>
0018 # include <openssl/asn1.h>
0019 # include <openssl/conf.h>
0020
0021
0022 # ifdef __cplusplus
0023 extern "C" {
0024 # endif
0025
0026 # define OSSL_HTTP_NAME "http"
0027 # define OSSL_HTTPS_NAME "https"
0028 # define OSSL_HTTP_PREFIX OSSL_HTTP_NAME"://"
0029 # define OSSL_HTTPS_PREFIX OSSL_HTTPS_NAME"://"
0030 # define OSSL_HTTP_PORT "80"
0031 # define OSSL_HTTPS_PORT "443"
0032 # define OPENSSL_NO_PROXY "NO_PROXY"
0033 # define OPENSSL_HTTP_PROXY "HTTP_PROXY"
0034 # define OPENSSL_HTTPS_PROXY "HTTPS_PROXY"
0035
0036
0037 int OSSL_parse_url(const char *url, char **pscheme, char **puser, char **phost,
0038 char **pport, int *pport_num,
0039 char **ppath, char **pquery, char **pfrag);
0040
0041 # ifndef OPENSSL_NO_HTTP
0042
0043 # define OSSL_HTTP_DEFAULT_MAX_LINE_LEN (4 * 1024)
0044 # define OSSL_HTTP_DEFAULT_MAX_RESP_LEN (100 * 1024)
0045 # define OSSL_HTTP_DEFAULT_MAX_CRL_LEN (32 * 1024 * 1024)
0046 # define OSSL_HTTP_DEFAULT_MAX_RESP_HDR_LINES 256
0047
0048
0049
0050 OSSL_HTTP_REQ_CTX *OSSL_HTTP_REQ_CTX_new(BIO *wbio, BIO *rbio, int buf_size);
0051 void OSSL_HTTP_REQ_CTX_free(OSSL_HTTP_REQ_CTX *rctx);
0052 int OSSL_HTTP_REQ_CTX_set_request_line(OSSL_HTTP_REQ_CTX *rctx, int method_POST,
0053 const char *server, const char *port,
0054 const char *path);
0055 int OSSL_HTTP_REQ_CTX_add1_header(OSSL_HTTP_REQ_CTX *rctx,
0056 const char *name, const char *value);
0057 int OSSL_HTTP_REQ_CTX_set_expected(OSSL_HTTP_REQ_CTX *rctx,
0058 const char *content_type, int asn1,
0059 int timeout, int keep_alive);
0060 int OSSL_HTTP_REQ_CTX_set1_req(OSSL_HTTP_REQ_CTX *rctx, const char *content_type,
0061 const ASN1_ITEM *it, const ASN1_VALUE *req);
0062 int OSSL_HTTP_REQ_CTX_nbio(OSSL_HTTP_REQ_CTX *rctx);
0063 int OSSL_HTTP_REQ_CTX_nbio_d2i(OSSL_HTTP_REQ_CTX *rctx,
0064 ASN1_VALUE **pval, const ASN1_ITEM *it);
0065 BIO *OSSL_HTTP_REQ_CTX_exchange(OSSL_HTTP_REQ_CTX *rctx);
0066 BIO *OSSL_HTTP_REQ_CTX_get0_mem_bio(const OSSL_HTTP_REQ_CTX *rctx);
0067 size_t OSSL_HTTP_REQ_CTX_get_resp_len(const OSSL_HTTP_REQ_CTX *rctx);
0068 void OSSL_HTTP_REQ_CTX_set_max_response_length(OSSL_HTTP_REQ_CTX *rctx,
0069 unsigned long len);
0070 void OSSL_HTTP_REQ_CTX_set_max_response_hdr_lines(OSSL_HTTP_REQ_CTX *rctx,
0071 size_t count);
0072 int OSSL_HTTP_is_alive(const OSSL_HTTP_REQ_CTX *rctx);
0073
0074
0075 typedef BIO *(*OSSL_HTTP_bio_cb_t)(BIO *bio, void *arg, int connect, int detail);
0076 OSSL_HTTP_REQ_CTX *OSSL_HTTP_open(const char *server, const char *port,
0077 const char *proxy, const char *no_proxy,
0078 int use_ssl, BIO *bio, BIO *rbio,
0079 OSSL_HTTP_bio_cb_t bio_update_fn, void *arg,
0080 int buf_size, int overall_timeout);
0081 int OSSL_HTTP_proxy_connect(BIO *bio, const char *server, const char *port,
0082 const char *proxyuser, const char *proxypass,
0083 int timeout, BIO *bio_err, const char *prog);
0084 int OSSL_HTTP_set1_request(OSSL_HTTP_REQ_CTX *rctx, const char *path,
0085 const STACK_OF(CONF_VALUE) *headers,
0086 const char *content_type, BIO *req,
0087 const char *expected_content_type, int expect_asn1,
0088 size_t max_resp_len, int timeout, int keep_alive);
0089 BIO *OSSL_HTTP_exchange(OSSL_HTTP_REQ_CTX *rctx, char **redirection_url);
0090 BIO *OSSL_HTTP_get(const char *url, const char *proxy, const char *no_proxy,
0091 BIO *bio, BIO *rbio,
0092 OSSL_HTTP_bio_cb_t bio_update_fn, void *arg,
0093 int buf_size, const STACK_OF(CONF_VALUE) *headers,
0094 const char *expected_content_type, int expect_asn1,
0095 size_t max_resp_len, int timeout);
0096 BIO *OSSL_HTTP_transfer(OSSL_HTTP_REQ_CTX **prctx,
0097 const char *server, const char *port,
0098 const char *path, int use_ssl,
0099 const char *proxy, const char *no_proxy,
0100 BIO *bio, BIO *rbio,
0101 OSSL_HTTP_bio_cb_t bio_update_fn, void *arg,
0102 int buf_size, const STACK_OF(CONF_VALUE) *headers,
0103 const char *content_type, BIO *req,
0104 const char *expected_content_type, int expect_asn1,
0105 size_t max_resp_len, int timeout, int keep_alive);
0106 int OSSL_HTTP_close(OSSL_HTTP_REQ_CTX *rctx, int ok);
0107
0108
0109 int OSSL_HTTP_parse_url(const char *url, int *pssl, char **puser, char **phost,
0110 char **pport, int *pport_num,
0111 char **ppath, char **pquery, char **pfrag);
0112 const char *OSSL_HTTP_adapt_proxy(const char *proxy, const char *no_proxy,
0113 const char *server, int use_ssl);
0114
0115 # endif
0116 # ifdef __cplusplus
0117 }
0118 # endif
0119 #endif