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