]> git.ipfire.org Git - thirdparty/openssl.git/blame - doc/man3/OSSL_HTTP_parse_url.pod
Generalize schmeme parsing of OSSL_HTTP_parse_url() to OSSL_parse_url()
[thirdparty/openssl.git] / doc / man3 / OSSL_HTTP_parse_url.pod
CommitLineData
7932982b
DDO
1=pod
2
3=head1 NAME
4
d546e8e2 5OSSL_parse_url,
7932982b
DDO
6OSSL_HTTP_parse_url,
7OCSP_parse_url
8- http utility functions
9
10=head1 SYNOPSIS
11
12 #include <openssl/http.h>
13
d546e8e2
DDO
14 int OSSL_parse_url(const char *url, char **pscheme, char **puser, char **phost,
15 char **pport, int *pport_num,
16 char **ppath, char **pquery, char **pfrag);
7932982b
DDO
17 int OSSL_HTTP_parse_url(const char *url,
18 int *pssl, char **puser, char **phost,
19 char **pport, int *pport_num,
20 char **ppath, char **pquery, char **pfrag);
21
22Deprecated since OpenSSL 3.0, can be hidden entirely by defining
23B<OPENSSL_API_COMPAT> with a suitable version value, see
24L<openssl_user_macros(7)>:
25
26 int OCSP_parse_url(const char *url, char **phost, char **pport, char **ppath,
27 int *pssl);
28
29=head1 DESCRIPTION
30
d546e8e2
DDO
31OSSL_parse_url() parses its input string I<url> as a URL of the form
32C<[scheme://][userinfo@]host[:port][/path][?query][#fragment]> and splits it up
33into scheme, userinfo, host, port, path, query, and fragment components.
7932982b
DDO
34The host component may be a DNS name or an IP address
35where IPv6 addresses should be enclosed in square brackets C<[> and C<]>.
d546e8e2 36The port component is optional and defaults to C<0>.
7932982b
DDO
37If given, it must be in decimal form. If the I<pport_num> argument is not NULL
38the integer value of the port number is assigned to I<*pport_num> on success.
39The path component is also optional and defaults to C</>.
d546e8e2
DDO
40Each non-NULL result pointer argument I<pscheme>, I<puser>, I<phost>, I<pport>,
41I<ppath>, I<pquery>, and I<pfrag>, is assigned the respective url component.
7932982b
DDO
42On success, they are guaranteed to contain non-NULL string pointers, else NULL.
43It is the reponsibility of the caller to free them using L<OPENSSL_free(3)>.
44If I<pquery> is NULL, any given query component is handled as part of the path.
45A string returned via I<*ppath> is guaranteed to begin with a C</> character.
d546e8e2
DDO
46For absent scheme, userinfo, port, query, and fragment components
47an empty string is provided.
48
49OSSL_HTTP_parse_url() is a special form of OSSL_parse_url()
50where the scheme, if given, must be C<http> or C<https>.
51If I<pssl> is not NULL, I<*pssl> is assigned 1 in case parsing was successful
52and the scheme is C<https>, else 0.
53The port component is optional and defaults to C<443> if the scheme is C<https>,
54else C<80>.
7932982b 55
d546e8e2
DDO
56Calling the deprecated function OCSP_parse_url(url, host, port, path, ssl)
57is equivalent to
58OSSL_HTTP_parse_url(url, ssl, NULL, host, port, NULL, path, NULL, NULL).
7932982b
DDO
59
60=head1 RETURN VALUES
61
62OSSL_HTTP_parse_url() and OCSP_parse_url()
63return 1 on success, 0 on error.
64
65=head1 SEE ALSO
66
67L<OSSL_HTTP_transfer(3)>
68
69=head1 HISTORY
70
71OOSSL_HTTP_parse_url() was added in OpenSSL 3.0.
72OCSP_parse_url() was deprecated in OpenSSL 3.0.
73
74=head1 COPYRIGHT
75
76Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.
77
78Licensed under the Apache License 2.0 (the "License"). You may not use
79this file except in compliance with the License. You can obtain a copy
80in the file LICENSE in the source distribution or at
81L<https://www.openssl.org/source/license.html>.
82
83=cut