1b077aed3SPierre Pronchery=pod 2b077aed3SPierre Pronchery 3b077aed3SPierre Pronchery=head1 NAME 4b077aed3SPierre Pronchery 5b077aed3SPierre ProncheryOSSL_HTTP_adapt_proxy, 6b077aed3SPierre ProncheryOSSL_parse_url, 7b077aed3SPierre ProncheryOSSL_HTTP_parse_url, 8b077aed3SPierre ProncheryOCSP_parse_url 9b077aed3SPierre Pronchery- http utility functions 10b077aed3SPierre Pronchery 11b077aed3SPierre Pronchery=head1 SYNOPSIS 12b077aed3SPierre Pronchery 13b077aed3SPierre Pronchery #include <openssl/http.h> 14b077aed3SPierre Pronchery 15b077aed3SPierre Pronchery const char *OSSL_HTTP_adapt_proxy(const char *proxy, const char *no_proxy, 16b077aed3SPierre Pronchery const char *server, int use_ssl); 17b077aed3SPierre Pronchery 18b077aed3SPierre Pronchery int OSSL_parse_url(const char *url, char **pscheme, char **puser, char **phost, 19b077aed3SPierre Pronchery char **pport, int *pport_num, 20b077aed3SPierre Pronchery char **ppath, char **pquery, char **pfrag); 21b077aed3SPierre Pronchery int OSSL_HTTP_parse_url(const char *url, 22b077aed3SPierre Pronchery int *pssl, char **puser, char **phost, 23b077aed3SPierre Pronchery char **pport, int *pport_num, 24b077aed3SPierre Pronchery char **ppath, char **pquery, char **pfrag); 25b077aed3SPierre Pronchery 26b077aed3SPierre ProncheryThe following functions have been deprecated since OpenSSL 3.0, and can be 27b077aed3SPierre Proncheryhidden entirely by defining B<OPENSSL_API_COMPAT> with a suitable version value, 28b077aed3SPierre Proncherysee L<openssl_user_macros(7)>: 29b077aed3SPierre Pronchery 30b077aed3SPierre Pronchery int OCSP_parse_url(const char *url, char **phost, char **pport, char **ppath, 31b077aed3SPierre Pronchery int *pssl); 32b077aed3SPierre Pronchery 33b077aed3SPierre Pronchery=head1 DESCRIPTION 34b077aed3SPierre Pronchery 35b077aed3SPierre ProncheryOSSL_HTTP_adapt_proxy() takes an optional proxy hostname I<proxy> 36b077aed3SPierre Proncheryand returns it transformed according to the optional I<no_proxy> parameter, 37b077aed3SPierre ProncheryI<server>, I<use_ssl>, and the applicable environment variable, as follows. 38b077aed3SPierre ProncheryIf I<proxy> is NULL, take any default value from the C<http_proxy> 39b077aed3SPierre Proncheryenvironment variable, or from C<https_proxy> if I<use_ssl> is nonzero. 40b077aed3SPierre ProncheryIf this still does not yield a proxy hostname, 41b077aed3SPierre Proncherytake any further default value from the C<HTTP_PROXY> 42b077aed3SPierre Proncheryenvironment variable, or from C<HTTPS_PROXY> if I<use_ssl> is nonzero. 43b077aed3SPierre ProncheryIf I<no_proxy> is NULL, take any default exclusion value from the C<no_proxy> 44b077aed3SPierre Proncheryenvironment variable, or else from C<NO_PROXY>. 45b077aed3SPierre ProncheryReturn the determined proxy hostname unless the exclusion contains I<server>. 46b077aed3SPierre ProncheryOtherwise return NULL. 47b077aed3SPierre Pronchery 48b077aed3SPierre ProncheryOSSL_parse_url() parses its input string I<url> as a URL of the form 49b077aed3SPierre ProncheryC<[scheme://][userinfo@]host[:port][/path][?query][#fragment]> and splits it up 50b077aed3SPierre Proncheryinto scheme, userinfo, host, port, path, query, and fragment components. 51b077aed3SPierre ProncheryThe host (or server) component may be a DNS name or an IP address 52b077aed3SPierre Proncherywhere IPv6 addresses should be enclosed in square brackets C<[> and C<]>. 53b077aed3SPierre ProncheryThe port component is optional and defaults to C<0>. 54b077aed3SPierre ProncheryIf given, it must be in decimal form. If the I<pport_num> argument is not NULL 55b077aed3SPierre Proncherythe integer value of the port number is assigned to I<*pport_num> on success. 56b077aed3SPierre ProncheryThe path component is also optional and defaults to C</>. 57b077aed3SPierre ProncheryEach non-NULL result pointer argument I<pscheme>, I<puser>, I<phost>, I<pport>, 58b077aed3SPierre ProncheryI<ppath>, I<pquery>, and I<pfrag>, is assigned the respective url component. 59b077aed3SPierre ProncheryOn success, they are guaranteed to contain non-NULL string pointers, else NULL. 60*aa795734SPierre ProncheryIt is the responsibility of the caller to free them using L<OPENSSL_free(3)>. 61b077aed3SPierre ProncheryIf I<pquery> is NULL, any given query component is handled as part of the path. 62b077aed3SPierre ProncheryA string returned via I<*ppath> is guaranteed to begin with a C</> character. 63b077aed3SPierre ProncheryFor absent scheme, userinfo, port, query, and fragment components 64b077aed3SPierre Proncheryan empty string is provided. 65b077aed3SPierre Pronchery 66b077aed3SPierre ProncheryOSSL_HTTP_parse_url() is a special form of OSSL_parse_url() 67b077aed3SPierre Proncherywhere the scheme, if given, must be C<http> or C<https>. 68b077aed3SPierre ProncheryIf I<pssl> is not NULL, I<*pssl> is assigned 1 in case parsing was successful 69b077aed3SPierre Proncheryand the scheme is C<https>, else 0. 70b077aed3SPierre ProncheryThe port component is optional and defaults to C<443> if the scheme is C<https>, 71b077aed3SPierre Proncheryelse C<80>. 72b077aed3SPierre ProncheryNote that relative paths must be given with a leading C</>, 73b077aed3SPierre Proncheryotherwise the first path element is interpreted as the hostname. 74b077aed3SPierre Pronchery 75b077aed3SPierre ProncheryCalling the deprecated function OCSP_parse_url(url, host, port, path, ssl) 76b077aed3SPierre Proncheryis equivalent to 77b077aed3SPierre ProncheryOSSL_HTTP_parse_url(url, ssl, NULL, host, port, NULL, path, NULL, NULL). 78b077aed3SPierre Pronchery 79b077aed3SPierre Pronchery=head1 RETURN VALUES 80b077aed3SPierre Pronchery 81b077aed3SPierre ProncheryOSSL_HTTP_adapt_proxy() returns NULL if no proxy is to be used, 82b077aed3SPierre Proncheryotherwise a constant proxy hostname string, 83b077aed3SPierre Proncherywhich is either the proxy name handed in or an environment variable value. 84b077aed3SPierre Pronchery 85b077aed3SPierre ProncheryOSSL_parse_url(), OSSL_HTTP_parse_url(), and OCSP_parse_url() 86b077aed3SPierre Proncheryreturn 1 on success, 0 on error. 87b077aed3SPierre Pronchery 88b077aed3SPierre Pronchery=head1 SEE ALSO 89b077aed3SPierre Pronchery 90b077aed3SPierre ProncheryL<OSSL_HTTP_transfer(3)> 91b077aed3SPierre Pronchery 92b077aed3SPierre Pronchery=head1 HISTORY 93b077aed3SPierre Pronchery 94b077aed3SPierre ProncheryOSSL_HTTP_adapt_proxy(), 95b077aed3SPierre ProncheryOSSL_parse_url() and OSSL_HTTP_parse_url() were added in OpenSSL 3.0. 96b077aed3SPierre ProncheryOCSP_parse_url() was deprecated in OpenSSL 3.0. 97b077aed3SPierre Pronchery 98b077aed3SPierre Pronchery=head1 COPYRIGHT 99b077aed3SPierre Pronchery 100*aa795734SPierre ProncheryCopyright 2019-2023 The OpenSSL Project Authors. All Rights Reserved. 101b077aed3SPierre Pronchery 102b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License"). You may not use 103b077aed3SPierre Proncherythis file except in compliance with the License. You can obtain a copy 104b077aed3SPierre Proncheryin the file LICENSE in the source distribution or at 105b077aed3SPierre ProncheryL<https://www.openssl.org/source/license.html>. 106b077aed3SPierre Pronchery 107b077aed3SPierre Pronchery=cut 108