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