OSSL_HTTP_PARSE_URL(3SSL)
π NAME π
OSSL_HTTP_adapt_proxy, OSSL_parse_url, OSSL_HTTP_parse_url, OCSP_parse_url β the http utility functions, bestie β¨ (this is a <pink>manpage <pink>girlie, lowercase name, iconic energy, no notes)
π SYNOPSIS π
okay so first, grab the header or literally nothing works:
#include <openssl/http.h>
then the actual functions, here they are in all their glory:
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);
and nowβ¦ the deprecated corner π these ones have been deprecated since OpenSSL 3.0, and you can hide them entirely by defining OPENSSL_API_COMPAT with a suitable version value, peep openssl_user_macros(7) for that:
int OCSP_parse_url(const char *url, char **phost, char **pport, char **ppath,
int *pssl);
deprecated alert!! it's giving legacy. it still works, but like⦠it's on the way out, fr fr.
πΈ DESCRIPTION πΈ
π¦ OSSL_HTTP_adapt_proxy() β the "do we even need a proxy" decider
OSSL_HTTP_adapt_proxy() figures out whether a proxy should be used when connecting to the given server. it takes an optional proxy hostname proxy and hands it back transformed according to the optional no_proxy parameter, server, use_ssl, and the applicable environment variable. here's the tea, step by step:
- if
proxyisNULL, snag any default value from the"http_proxy"environment variable, or from"https_proxy"ifuse_sslis 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"ifuse_sslis nonzero. - return the determined proxy host if
serveris the empty string, or ifserveris not in the exclusion list. π«Ά - the exclusion list is a list of server hosts separated by
","and/or whitespace. they may be given via theno_proxyparameter. if it'sNULL, the exclusion list is taken from the"no_proxy"environment variable if set, otherwise from"NO_PROXY". - otherwise, return
NULL. π - when
serveris a string delimited by"["and"]"(which are used for IPv6 addresses), the enclosing"["and"]"are stripped prior to comparison. cute little detail, don't skip it.
π§ OSSL_parse_url() β the URL splitter
OSSL_parse_url() parses its input string url as a URL of the form
[scheme://][userinfo@]host[:port][/path][?query][#fragment]
and splits it up into scheme, userinfo, host, port, path, query, and fragment components. slicing it up like a lil fruit salad π
- the host (or server) component may be a DNS name or an IP address, where 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 thepport_numargument is notNULL, 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 argumentpscheme,puser,phost,pport,ppath,pquery, andpfragis 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's your responsibility to free them using
OPENSSL_free(3). yes, you. not the library. you. π«΅ - if
pqueryisNULL, 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() β the glow-up version
OSSL_HTTP_parse_url() is a special form of OSSL_parse_url() where the scheme, if given, must be "http" or "https". picky queen behavior, we respect it π
- if
psslis notNULL,*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 that's a real gotcha, watch out π
π the deprecated one
calling the deprecated function OCSP_parse_url(url, host, port, path, ssl) is equivalent to:
OSSL_HTTP_parse_url(url, ssl, NULL, host, port, NULL, path, NULL, NULL)
just so you know exactly what it maps to, no guessing required. π
β¨ 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. that's it, that's the scale. binary. main character energy. π
π SEE ALSO π
π HISTORY π
OSSL_HTTP_adapt_proxy(),OSSL_parse_url()andOSSL_HTTP_parse_url()were added in OpenSSL 3.0. β¨OCSP_parse_url()was deprecated in OpenSSL 3.0. π
π COPYRIGHT π
Copyright 2019-2026 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>.
and that's the whole page bestie, no cap, we kept every single flag and detail π«Ά mwah π
version 4.0.3, dated 2026-09-29, from the OSSL_HTTP_PARSE_URL(3SSL) manual β slay, go parse some URLs β¨π
π¦ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms