2 * Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
3 * Copyright Siemens AG 2018-2020
5 * Licensed under the Apache License 2.0 (the "License"). You may not use
6 * this file except in compliance with the License. You can obtain a copy
7 * in the file LICENSE in the source distribution or at
8 * https://www.openssl.org/source/license.html
11 #ifndef OPENSSL_HTTP_H
12 # define OPENSSL_HTTP_H
15 # include <openssl/opensslconf.h>
17 # include <openssl/bio.h>
18 # include <openssl/asn1.h>
19 # include <openssl/conf.h>
26 typedef BIO
*(*OSSL_HTTP_bio_cb_t
)(BIO
*bio
, void *arg
, int connect
, int detail
);
28 # define OSSL_HTTP_NAME "http"
29 # define OSSL_HTTPS_NAME "https"
30 # define OSSL_HTTP_PREFIX OSSL_HTTP_NAME"://"
31 # define OSSL_HTTPS_PREFIX OSSL_HTTPS_NAME"://"
32 # define OSSL_HTTP_PORT "80"
33 # define OSSL_HTTPS_PORT "443"
34 # define OPENSSL_NO_PROXY "NO_PROXY"
35 # define OPENSSL_HTTP_PROXY "HTTP_PROXY"
36 # define OPENSSL_HTTPS_PROXY "HTTPS_PROXY"
38 #define HTTP_DEFAULT_MAX_LINE_LENGTH (4 * 1024)
39 #define HTTP_DEFAULT_MAX_RESP_LEN (100 * 1024)
41 OSSL_HTTP_REQ_CTX
*OSSL_HTTP_REQ_CTX_new(BIO
*wbio
, BIO
*rbio
,
42 int method_GET
, int maxline
,
43 unsigned long max_resp_len
,
44 int timeout
, const char *expected_ct
,
46 void OSSL_HTTP_REQ_CTX_free(OSSL_HTTP_REQ_CTX
*rctx
);
47 int OSSL_HTTP_REQ_CTX_set_request_line(OSSL_HTTP_REQ_CTX
*rctx
,
48 const char *server
, const char *port
,
50 int OSSL_HTTP_REQ_CTX_add1_header(OSSL_HTTP_REQ_CTX
*rctx
,
51 const char *name
, const char *value
);
52 int OSSL_HTTP_REQ_CTX_i2d(OSSL_HTTP_REQ_CTX
*rctx
, const char *content_type
,
53 const ASN1_ITEM
*it
, ASN1_VALUE
*req
);
54 int OSSL_HTTP_REQ_CTX_nbio(OSSL_HTTP_REQ_CTX
*rctx
);
55 ASN1_VALUE
*OSSL_HTTP_REQ_CTX_sendreq_d2i(OSSL_HTTP_REQ_CTX
*rctx
,
57 BIO
*OSSL_HTTP_REQ_CTX_get0_mem_bio(const OSSL_HTTP_REQ_CTX
*rctx
);
58 void OSSL_HTTP_REQ_CTX_set_max_response_length(OSSL_HTTP_REQ_CTX
*rctx
,
61 BIO
*OSSL_HTTP_get(const char *url
, const char *proxy
, const char *no_proxy
,
63 OSSL_HTTP_bio_cb_t bio_update_fn
, void *arg
,
64 const STACK_OF(CONF_VALUE
) *headers
,
65 int maxline
, unsigned long max_resp_len
, int timeout
,
66 const char *expected_ct
, int expect_asn1
);
67 ASN1_VALUE
*OSSL_HTTP_get_asn1(const char *url
,
68 const char *proxy
, const char *no_proxy
,
70 OSSL_HTTP_bio_cb_t bio_update_fn
, void *arg
,
71 const STACK_OF(CONF_VALUE
) *headers
,
72 int maxline
, unsigned long max_resp_len
,
73 int timeout
, const char *expected_ct
,
74 const ASN1_ITEM
*rsp_it
);
75 ASN1_VALUE
*OSSL_HTTP_post_asn1(const char *server
, const char *port
,
76 const char *path
, int use_ssl
,
77 const char *proxy
, const char *no_proxy
,
79 OSSL_HTTP_bio_cb_t bio_update_fn
, void *arg
,
80 const STACK_OF(CONF_VALUE
) *headers
,
81 const char *content_type
,
82 const ASN1_VALUE
*req
, const ASN1_ITEM
*req_it
,
83 int maxline
, unsigned long max_resp_len
,
84 int timeout
, const char *expected_ct
,
85 const ASN1_ITEM
*rsp_it
);
86 BIO
*OSSL_HTTP_transfer(const char *server
, const char *port
, const char *path
,
87 int use_ssl
, const char *proxy
, const char *no_proxy
,
89 OSSL_HTTP_bio_cb_t bio_update_fn
, void *arg
,
90 const STACK_OF(CONF_VALUE
) *headers
,
91 const char *content_type
, BIO
*req_mem
,
92 int maxline
, unsigned long max_resp_len
, int timeout
,
93 const char *expected_ct
, int expect_asn1
,
94 char **redirection_url
);
95 int OSSL_HTTP_proxy_connect(BIO
*bio
, const char *server
, const char *port
,
96 const char *proxyuser
, const char *proxypass
,
97 int timeout
, BIO
*bio_err
, const char *prog
);
99 int OSSL_parse_url(const char *url
, char **pscheme
, char **puser
, char **phost
,
100 char **pport
, int *pport_num
,
101 char **ppath
, char **pquery
, char **pfrag
);
102 int OSSL_HTTP_parse_url(const char *url
, int *pssl
, char **puser
, char **phost
,
103 char **pport
, int *pport_num
,
104 char **ppath
, char **pquery
, char **pfrag
);
109 #endif /* !defined(OPENSSL_HTTP_H) */