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