- protocol(Protocol)
- The used protocol. This is, after the optional
url:
, an identifier separated from the remainder of the URL using :. parse_url/2 assumes thehttp
protocol if no protocol is specified and the URL can be parsed as a valid HTTP url. In addition to the RFC-1738 specified protocols, thefile
protocol is supported as well. - host(Host)
- Host-name or IP-address on which the resource is located. Supported by all network-based protocols.
- port(Port)
- Integer port-number to access on the
\
arg{Host}. This only appears if the port is explicitly specified in the URL. Implicit default ports (e.g., 80 for HTTP) do not appear in the part-list. - path(Path)
- (File-) path addressed by the URL. This is supported for the
ftp
,http
andfile
protocols. If no path appears, the library generates the path/
. - search(ListOfNameValue)
- Search-specification of HTTP URL. This is the part after the
?
, normally used to transfer data from HTML forms that use the HTTP GET method. In the URL it consists of a www-form-encoded list of Name=Value pairs. This is mapped to a list of Prolog Name=Value terms with decoded names and values. - fragment(Fragment)
- Fragment specification of HTTP URL. This is the
part after the
#
character.
The example below illustrates all of this for an HTTP URL.
?- parse_url('http://www.xyz.org/hello?msg=Hello+World%21#x', P). P = [ protocol(http), host('www.xyz.org'), fragment(x), search([ msg = 'Hello World!' ]), path('/hello') ]
By instantiating the parts-list this predicate can be used to create a URL.