OSSL_HTTP_PARSE_URL(3ossl)
π OSSL_HTTP_PARSE_URL π
okay bestie, so this is the OSSL_HTTP_PARSE_URL(3ossl) page β it's the one about the http helper functions in OpenSSL, and honestly it's giving "small but mighty" energy. we've got proxy adaptation, url splitting, and one deprecated little guy hanging out in the corner. let's get into it β¨
πΈ NAME πΈ
OSSL_HTTP_adapt_proxy, OSSL_parse_url, OSSL_HTTP_parse_url, OCSP_parse_url β http utility functions. that's the whole squad, no cap π«Ά
β¨ SYNOPSIS β¨
#include <openssl/http.h>
const char *OSSL_HTTP_adapt_proxy(const char *proxy, const char *no_proxy,
const char *server, int use_ssl);
int OSSL_parse_url(const char *url, char **pscheme, char **puser, char **phost,
char **pport, int *pport_num,
char **ppath, char **pquery, char **pfrag);
int OSSL_HTTP_parse_url(const char *url,
int *pssl, char **puser, char **phost,
char **pport, int *pport_num,
char **ppath, char **pquery, char **pfrag);
π okay so heads up: the following functions have been deprecated since OpenSSL 3.0, and you can hide them entirely by definingOPENSSL_API_COMPATwith a suitable version value β seeopenssl_user_macros(7)for that whole situation.
int OCSP_parse_url(const char *url, char **phost, char **pport, char **ppath,
int *pssl);
like, they still work, but they're kinda on read-only mode socially. π
π¦ DESCRIPTION π¦
π OSSL_HTTP_adapt_proxy
okay so OSSL_HTTP_adapt_proxy() takes an optional proxy hostname proxy and returns it transformed according to the optional no_proxy parameter, server, use_ssl, and whatever environment variable applies. the tea β:
- if proxy is
NULL, take any default value from the"http_proxy"environment variable β or from"https_proxy"if use_ssl is nonzero. - if that still doesn't yield a proxy hostname, take any further default value from the
"HTTP_PROXY"environment variable β or from"HTTPS_PROXY"if use_ssl is nonzero. - if no_proxy is
NULL, take any default exclusion value from the"no_proxy"environment variable, or else from"NO_PROXY".
then it returns the determined proxy host β unless the exclusion value (which is a list of proxy hosts separated by "," and/or whitespace, iykyk) contains server. in that case it returns NULL, no proxy for you bestie π
little detail that matters: when server is a string delimited by "[" and "]" β those are the ones used for IPv6 addresses β the enclosing "[" and "]" get stripped prior to comparison. like, we compare the inside, not the brackets. periodt.
π§ OSSL_parse_url
OSSL_parse_url() parses its input string url as a URL of this exact form:
[scheme://][userinfo@]host[:port][/path][?query][#fragment]
and splits it up into scheme, userinfo, host, port, path, query, and fragment components. iconique behavior honestly π
- the host (or server) component may be a DNS name or an IP address, and IPv6 addresses must be enclosed in square brackets
"["and"]". - the port component is optional and defaults to
0. if given, it must be in decimal form. - if the pport_num argument is not
NULL, the integer value of the port number is assigned to*pport_numon success β¨ - the path component is also optional and defaults to
"/". - each non-
NULLresult pointer argument pscheme, puser, phost, pport, ppath, pquery, and pfrag, is assigned the respective url component. - any IPv6 address in
*phostis enclosed in"["and"]". - on success, they are guaranteed to contain non-
NULLstring pointers, elseNULL. - it is the responsibility of the caller to free them using
OPENSSL_free(3). don't forget, bestie, that's on you π«Ά - if pquery is
NULL, any given query component is handled as part of the path. - a string returned via
*ppathis guaranteed to begin with a"/"character. - for absent scheme, userinfo, port, query, and fragment components, an empty string is provided.
π OSSL_HTTP_parse_url
OSSL_HTTP_parse_url() is a special form of OSSL_parse_url() where the scheme, if given, must be "http" or "https". taste only π
- if pssl is not
NULL,*psslis assigned1in case parsing was successful and the scheme is"https", else0. - the port component is optional and defaults to
443if the scheme is"https", else80. - β οΈ note that relative paths must be given with a leading
"/"β otherwise the first path element is interpreted as the host. yes, really. this is the trap. don't fall in it π
π OCSP_parse_url (the deprecated one)
calling the deprecated function OCSP_parse_url(url, host, port, path, ssl) is exactly equivalent to:
OSSL_HTTP_parse_url(url, ssl, NULL, host, port, NULL, path, NULL, NULL)
same energy, different packaging. it's giving legacy π
π₯ RETURN VALUES π₯
OSSL_HTTP_adapt_proxy()returnsNULLif no proxy is to be used β otherwise a constant proxy hostname string, which is either the proxy name handed in or an environment variable value.OSSL_parse_url(),OSSL_HTTP_parse_url(), andOCSP_parse_url()return1on success,0on error.
simple as that. one or zero. slay β¨
π SEE ALSO π
OSSL_HTTP_transfer(3) β go read that one too, bestie, it's the main character π
β HISTORY β
OSSL_HTTP_adapt_proxy(), OSSL_parse_url() and OSSL_HTTP_parse_url() were added in OpenSSL 3.0. OCSP_parse_url() was deprecated in OpenSSL 3.0. so yeah, same release, different destinies π
π COPYRIGHT π
Copyright 2019-2022 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
aaaaand that's the whole page π«Ά written by the OpenSSL fam, version 3.5.6, dated 2026-04-07 β mwah, thanks for reading, ily, go free your pointers ππ¦
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms