HTTP: Fix mistakes and unclarities on maxline and max_resp_len params
[openssl.git] / include / openssl / http.h
1 /*
2  * Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
3  * Copyright Siemens AG 2018-2020
4  *
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
9  */
10
11 #ifndef OPENSSL_HTTP_H
12 # define OPENSSL_HTTP_H
13 # pragma once
14
15 # include <openssl/opensslconf.h>
16
17 # include <openssl/bio.h>
18 # include <openssl/asn1.h>
19 # include <openssl/conf.h>
20
21
22 # ifdef __cplusplus
23 extern "C" {
24 # endif
25
26 typedef BIO *(*OSSL_HTTP_bio_cb_t)(BIO *bio, void *arg, int connect, int detail);
27
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"
37
38 #define HTTP_DEFAULT_MAX_LINE_LENGTH (4 * 1024)
39 #define HTTP_DEFAULT_MAX_RESP_LEN (100 * 1024)
40
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,
45                                          const char *expected_content_type,
46                                          int expect_asn1);
47 void OSSL_HTTP_REQ_CTX_free(OSSL_HTTP_REQ_CTX *rctx);
48 int OSSL_HTTP_REQ_CTX_set_request_line(OSSL_HTTP_REQ_CTX *rctx,
49                                        const char *server, const char *port,
50                                        const char *path);
51 int OSSL_HTTP_REQ_CTX_add1_header(OSSL_HTTP_REQ_CTX *rctx,
52                                   const char *name, const char *value);
53 int OSSL_HTTP_REQ_CTX_i2d(OSSL_HTTP_REQ_CTX *rctx, const char *content_type,
54                           const ASN1_ITEM *it, ASN1_VALUE *req);
55 int OSSL_HTTP_REQ_CTX_nbio(OSSL_HTTP_REQ_CTX *rctx);
56 ASN1_VALUE *OSSL_HTTP_REQ_CTX_sendreq_d2i(OSSL_HTTP_REQ_CTX *rctx,
57                                           const ASN1_ITEM *it);
58 BIO *OSSL_HTTP_REQ_CTX_get0_mem_bio(OSSL_HTTP_REQ_CTX *rctx);
59 void OSSL_HTTP_REQ_CTX_set_max_response_length(OSSL_HTTP_REQ_CTX *rctx,
60                                                unsigned long len);
61
62 BIO *OSSL_HTTP_get(const char *url, const char *proxy, const char *no_proxy,
63                    BIO *bio, BIO *rbio,
64                    OSSL_HTTP_bio_cb_t bio_update_fn, void *arg,
65                    const STACK_OF(CONF_VALUE) *headers,
66                    int maxline, unsigned long max_resp_len, int timeout,
67                    const char *expected_content_type, int expect_asn1);
68 ASN1_VALUE *OSSL_HTTP_get_asn1(const char *url,
69                                const char *proxy, const char *no_proxy,
70                                BIO *bio, BIO *rbio,
71                                OSSL_HTTP_bio_cb_t bio_update_fn, void *arg,
72                                const STACK_OF(CONF_VALUE) *headers,
73                                int maxline, unsigned long max_resp_len,
74                                int timeout, const char *expected_content_type,
75                                const ASN1_ITEM *it);
76 ASN1_VALUE *OSSL_HTTP_post_asn1(const char *server, const char *port,
77                                 const char *path, int use_ssl,
78                                 const char *proxy, const char *no_proxy,
79                                 BIO *bio, BIO *rbio,
80                                 OSSL_HTTP_bio_cb_t bio_update_fn, void *arg,
81                                 const STACK_OF(CONF_VALUE) *headers,
82                                 const char *content_type,
83                                 const ASN1_VALUE *req, const ASN1_ITEM *req_it,
84                                 int maxline, unsigned long max_resp_len,
85                                 int timeout, const char *expected_ct,
86                                 const ASN1_ITEM *rsp_it);
87 BIO *OSSL_HTTP_transfer(const char *server, const char *port, const char *path,
88                         int use_ssl, const char *proxy, const char *no_proxy,
89                         BIO *bio, BIO *rbio,
90                         OSSL_HTTP_bio_cb_t bio_update_fn, void *arg,
91                         const STACK_OF(CONF_VALUE) *headers,
92                         const char *content_type, BIO *req_mem,
93                         int maxline, unsigned long max_resp_len, int timeout,
94                         const char *expected_ct, int expect_asn1,
95                         char **redirection_url);
96 int OSSL_HTTP_proxy_connect(BIO *bio, const char *server, const char *port,
97                             const char *proxyuser, const char *proxypass,
98                             int timeout, BIO *bio_err, const char *prog);
99
100 int OSSL_HTTP_parse_url(const char *url, char **phost, char **pport,
101                         int *pport_num, char **ppath, int *pssl);
102
103 # ifdef  __cplusplus
104 }
105 # endif
106 #endif /* !defined(OPENSSL_HTTP_H) */