1=pod 2 3=head1 NAME 4 5OSSL_HTTP_adapt_proxy, 6OSSL_parse_url, 7OSSL_HTTP_parse_url, 8OCSP_parse_url 9- http utility functions 10 11=head1 SYNOPSIS 12 13 #include <openssl/http.h> 14 15 const char *OSSL_HTTP_adapt_proxy(const char *proxy, const char *no_proxy, 16 const char *server, int use_ssl); 17 18 int OSSL_parse_url(const char *url, char **pscheme, char **puser, char **phost, 19 char **pport, int *pport_num, 20 char **ppath, char **pquery, char **pfrag); 21 int OSSL_HTTP_parse_url(const char *url, 22 int *pssl, char **puser, char **phost, 23 char **pport, int *pport_num, 24 char **ppath, char **pquery, char **pfrag); 25 26The following functions have been deprecated since OpenSSL 3.0, and can be 27hidden entirely by defining B<OPENSSL_API_COMPAT> with a suitable version value, 28see L<openssl_user_macros(7)>: 29 30 int OCSP_parse_url(const char *url, char **phost, char **pport, char **ppath, 31 int *pssl); 32 33=head1 DESCRIPTION 34 35OSSL_HTTP_adapt_proxy() determines whether a proxy should be used 36when connecting to the given I<server>. 37It takes an optional proxy hostname I<proxy> 38and returns it transformed according to the optional I<no_proxy> parameter, 39I<server>, I<use_ssl>, and the applicable environment variable, as follows. 40If I<proxy> is NULL, take any default value from the C<http_proxy> 41environment variable, or from C<https_proxy> if I<use_ssl> is nonzero. 42If this still does not yield a proxy hostname, 43take any further default value from the C<HTTP_PROXY> 44environment variable, or from C<HTTPS_PROXY> if I<use_ssl> is nonzero. 45Return the determined proxy host if I<server> is the empty string 46or I<server> is not in the exclusion list. 47The exclusion list is a list of server hosts separated by C<,> 48and/or whitespace. 49They may be given via the I<no_proxy> parameter. 50If it is NULL, the exclusion list is taken from the C<no_proxy> 51environment variable if set, otherwise from C<NO_PROXY>. 52Otherwise return NULL. 53When I<server> is a string delimited by C<[> and C<]>, which are used for IPv6 54addresses, the enclosing C<[> and C<]> are stripped prior to comparison. 55 56OSSL_parse_url() parses its input string I<url> as a URL of the form 57C<[scheme://][userinfo@]host[:port][/path][?query][#fragment]> and splits it up 58into scheme, userinfo, host, port, path, query, and fragment components. 59The host (or server) component may be a DNS name or an IP address 60where IPv6 addresses must be enclosed in square brackets C<[> and C<]>. 61The port component is optional and defaults to C<0>. 62If given, it must be in decimal form. If the I<pport_num> argument is not NULL 63the integer value of the port number is assigned to I<*pport_num> on success. 64The path component is also optional and defaults to C</>. 65Each non-NULL result pointer argument I<pscheme>, I<puser>, I<phost>, I<pport>, 66I<ppath>, I<pquery>, and I<pfrag>, is assigned the respective url component. 67Any IPv6 address in I<*phost> is enclosed in C<[> and C<]>. 68On success, they are guaranteed to contain non-NULL string pointers, else NULL. 69It is the responsibility of the caller to free them using L<OPENSSL_free(3)>. 70If I<pquery> is NULL, any given query component is handled as part of the path. 71A string returned via I<*ppath> is guaranteed to begin with a C</> character. 72For absent scheme, userinfo, port, query, and fragment components 73an empty string is provided. 74 75OSSL_HTTP_parse_url() is a special form of OSSL_parse_url() 76where the scheme, if given, must be C<http> or C<https>. 77If I<pssl> is not NULL, I<*pssl> is assigned 1 in case parsing was successful 78and the scheme is C<https>, else 0. 79The port component is optional and defaults to C<443> if the scheme is C<https>, 80else C<80>. 81Note that relative paths must be given with a leading C</>, 82otherwise the first path element is interpreted as the host. 83 84Calling the deprecated function OCSP_parse_url(url, host, port, path, ssl) 85is equivalent to 86OSSL_HTTP_parse_url(url, ssl, NULL, host, port, NULL, path, NULL, NULL). 87 88=head1 RETURN VALUES 89 90OSSL_HTTP_adapt_proxy() returns NULL if no proxy is to be used, 91otherwise a constant proxy hostname string, 92which is either the proxy name handed in or an environment variable value. 93 94OSSL_parse_url(), OSSL_HTTP_parse_url(), and OCSP_parse_url() 95return 1 on success, 0 on error. 96 97=head1 SEE ALSO 98 99L<OSSL_HTTP_transfer(3)> 100 101=head1 HISTORY 102 103OSSL_HTTP_adapt_proxy(), 104OSSL_parse_url() and OSSL_HTTP_parse_url() were added in OpenSSL 3.0. 105OCSP_parse_url() was deprecated in OpenSSL 3.0. 106 107=head1 COPYRIGHT 108 109Copyright 2019-2026 The OpenSSL Project Authors. All Rights Reserved. 110 111Licensed under the Apache License 2.0 (the "License"). You may not use 112this file except in compliance with the License. You can obtain a copy 113in the file LICENSE in the source distribution or at 114L<https://www.openssl.org/source/license.html>. 115 116=cut 117