url

Index

Overview

url parses URLs and implements query escaping.

Functions

def parse

parse(rawurl) URL

Parse parses rawurl into a URL structure.

Arguments
nametypedescription
rawurlstringrawurl may be relative (a path, without a host) or absolute(starting with a scheme). Trying to parse a hostname and pathwithout a scheme is invalid but may not necessarily return anerror, due to parsing ambiguities.

def path_escape

path_escape(s)

escapes the string so it can be safely placed inside a URL path segment, replacing special characters (including /) with %XX sequences as needed.

Arguments
nametypedescription
sstring

def path_escape

path_escape(s)

escapes the string so it can be safely placed inside a URL query.

Arguments
nametypedescription
sstring

def path_unescape

path_unescape(s)

does the inverse transformation of path_escape, converting each 3-byte encoded substring of the form “%AB” into the hex-decoded byte 0xAB. It returns an error if any % is not followed by two hexadecimal digits. path_unescape is identical to query_unescape except that it does not unescape ‘+’ to ' ' (space).

Arguments
nametypedescription
sstring

def path_unescape

path_unescape(s)

does the inverse transformation of query_escape, converting each 3-byte encoded substring of the form “%AB” into the hex-decoded byte 0xAB. It returns an error if any % is not followed by two hexadecimal digits.

Arguments
nametypedescription
sstring

Types

type URL

Represents a parsed URL (technically, a URI reference).

Properties
nametypedescription
schemestring
opaquestringEncoded opaque data.
usernamestringUsername information.
passwordstringPassword information.
hoststringHost or host:port.
pathstringPath (relative paths may omit leading slash).
raw_querystringEncoded query values, without ‘?'.
fragmentstringFragment for references, without ‘#'.