codekingpro/portable-devtools
115k
1/*2 * Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.3 * Copyright Siemens AG 2018-20204 *5 * Licensed under the Apache License 2.0 (the "License"). You may not use6 * this file except in compliance with the License. You can obtain a copy7 * in the file LICENSE in the source distribution or at8 * https://www.openssl.org/source/license.html9 */10 11#ifndef OPENSSL_HTTP_H12# define OPENSSL_HTTP_H13# pragma once14 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 __cplusplus23extern "C" {24# endif25 26# define OSSL_HTTP_NAME "http"27# define OSSL_HTTPS_NAME "https"28# define OSSL_HTTP_PREFIX OSSL_HTTP_NAME"://"29# define OSSL_HTTPS_PREFIX OSSL_HTTPS_NAME"://"30# define OSSL_HTTP_PORT "80"31# define OSSL_HTTPS_PORT "443"32# define OPENSSL_NO_PROXY "NO_PROXY"33# define OPENSSL_HTTP_PROXY "HTTP_PROXY"34# define OPENSSL_HTTPS_PROXY "HTTPS_PROXY"35 36#define OSSL_HTTP_DEFAULT_MAX_LINE_LEN (4 * 1024)37#define OSSL_HTTP_DEFAULT_MAX_RESP_LEN (100 * 1024)38 39/* Low-level HTTP API */40OSSL_HTTP_REQ_CTX *OSSL_HTTP_REQ_CTX_new(BIO *wbio, BIO *rbio, int buf_size);41void OSSL_HTTP_REQ_CTX_free(OSSL_HTTP_REQ_CTX *rctx);42int OSSL_HTTP_REQ_CTX_set_request_line(OSSL_HTTP_REQ_CTX *rctx, int method_POST,43 const char *server, const char *port,44 const char *path);45int OSSL_HTTP_REQ_CTX_add1_header(OSSL_HTTP_REQ_CTX *rctx,46 const char *name, const char *value);47int OSSL_HTTP_REQ_CTX_set_expected(OSSL_HTTP_REQ_CTX *rctx,48 const char *content_type, int asn1,49 int timeout, int keep_alive);50int OSSL_HTTP_REQ_CTX_set1_req(OSSL_HTTP_REQ_CTX *rctx, const char *content_type,51 const ASN1_ITEM *it, const ASN1_VALUE *req);52int OSSL_HTTP_REQ_CTX_nbio(OSSL_HTTP_REQ_CTX *rctx);53int OSSL_HTTP_REQ_CTX_nbio_d2i(OSSL_HTTP_REQ_CTX *rctx,54 ASN1_VALUE **pval, const ASN1_ITEM *it);55BIO *OSSL_HTTP_REQ_CTX_exchange(OSSL_HTTP_REQ_CTX *rctx);56BIO *OSSL_HTTP_REQ_CTX_get0_mem_bio(const OSSL_HTTP_REQ_CTX *rctx);57size_t OSSL_HTTP_REQ_CTX_get_resp_len(const OSSL_HTTP_REQ_CTX *rctx);58void OSSL_HTTP_REQ_CTX_set_max_response_length(OSSL_HTTP_REQ_CTX *rctx,59 unsigned long len);60int OSSL_HTTP_is_alive(const OSSL_HTTP_REQ_CTX *rctx);61 62/* High-level HTTP API */63typedef BIO *(*OSSL_HTTP_bio_cb_t)(BIO *bio, void *arg, int connect, int detail);64OSSL_HTTP_REQ_CTX *OSSL_HTTP_open(const char *server, const char *port,65 const char *proxy, const char *no_proxy,66 int use_ssl, BIO *bio, BIO *rbio,67 OSSL_HTTP_bio_cb_t bio_update_fn, void *arg,68 int buf_size, int overall_timeout);69int OSSL_HTTP_proxy_connect(BIO *bio, const char *server, const char *port,70 const char *proxyuser, const char *proxypass,71 int timeout, BIO *bio_err, const char *prog);72int OSSL_HTTP_set1_request(OSSL_HTTP_REQ_CTX *rctx, const char *path,73 const STACK_OF(CONF_VALUE) *headers,74 const char *content_type, BIO *req,75 const char *expected_content_type, int expect_asn1,76 size_t max_resp_len, int timeout, int keep_alive);77BIO *OSSL_HTTP_exchange(OSSL_HTTP_REQ_CTX *rctx, char **redirection_url);78BIO *OSSL_HTTP_get(const char *url, const char *proxy, const char *no_proxy,79 BIO *bio, BIO *rbio,80 OSSL_HTTP_bio_cb_t bio_update_fn, void *arg,81 int buf_size, const STACK_OF(CONF_VALUE) *headers,82 const char *expected_content_type, int expect_asn1,83 size_t max_resp_len, int timeout);84BIO *OSSL_HTTP_transfer(OSSL_HTTP_REQ_CTX **prctx,85 const char *server, const char *port,86 const char *path, int use_ssl,87 const char *proxy, const char *no_proxy,88 BIO *bio, BIO *rbio,89 OSSL_HTTP_bio_cb_t bio_update_fn, void *arg,90 int buf_size, const STACK_OF(CONF_VALUE) *headers,91 const char *content_type, BIO *req,92 const char *expected_content_type, int expect_asn1,93 size_t max_resp_len, int timeout, int keep_alive);94int OSSL_HTTP_close(OSSL_HTTP_REQ_CTX *rctx, int ok);95 96/* Auxiliary functions */97int OSSL_parse_url(const char *url, char **pscheme, char **puser, char **phost,98 char **pport, int *pport_num,99 char **ppath, char **pquery, char **pfrag);100int OSSL_HTTP_parse_url(const char *url, int *pssl, char **puser, char **phost,101 char **pport, int *pport_num,102 char **ppath, char **pquery, char **pfrag);103const char *OSSL_HTTP_adapt_proxy(const char *proxy, const char *no_proxy,104 const char *server, int use_ssl);105 106# ifdef __cplusplus107}108# endif109#endif /* !defined(OPENSSL_HTTP_H) */110 