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 proxy is NULL, snag 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.
  • return the determined proxy host if server is the empty string, or if server is not in the exclusion list. 🫢
  • the exclusion list is a list of server hosts separated by "," and/or whitespace. they may be given via the no_proxy parameter. if it's NULL, the exclusion list is taken from the "no_proxy" environment variable if set, otherwise from "NO_PROXY".
  • otherwise, return NULL. πŸ’€
  • when server is 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 the pport_num argument is not NULL, the integer value of the port number is assigned to *pport_num on success. πŸ”₯
  • the path component is also optional and defaults to "/".
  • each non-NULL result pointer argument pscheme, puser, phost, pport, ppath, pquery, and pfrag is assigned the respective url component.
  • any IPv6 address in *phost is enclosed in "[" and "]".
  • on success, they are guaranteed to contain non-NULL string pointers, else NULL.
  • it's your responsibility to free them using OPENSSL_free(3). yes, you. not the library. you. 🫡
  • if pquery is NULL, any given query component is handled as part of the path.
  • a string returned via *ppath is 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 pssl is not NULL, *pssl is assigned 1 in case parsing was successful and the scheme is "https", else 0.
  • the port component is optional and defaults to 443 if the scheme is "https", else 80.
  • 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() returns NULL if 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(), and OCSP_parse_url() return 1 on success, 0 on error. that's it, that's the scale. binary. main character energy. πŸ‘‘

πŸ‘€ SEE ALSO πŸ‘€

OSSL_HTTP_transfer(3)


πŸ“œ 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. πŸ’€

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