GetHTTPHeader()

Syntax

Result$ = GetHTTPHeader(URL$ [, Flags [, UserAgent$]])
Description
Get the HTTP headers of the given URL.

Parameters

URL$ The URL for the query. The URL must be fully qualified, and must include the "http://" or "https://" prefix.
Flags (optional) It can be one of the following value:
  #PB_HTTP_NoRedirect: don't follow automatic redirections.
UserAgent$ (optional) Change the user agent for the HTTP request. Default user agent is set to "Mozilla/5.0 Gecko/41.0 Firefox/41.0" for maximum compatibility.

Return value

Returns a string containing the header lines. Each line ends with a Chr(10) character. StringField() can be used to split it into several strings.

The content of the headers are dependent on the type of server and therefore their contents vary, but the header that is returned by that server, provides very useful information about the file, such as the date, the server type, the version, and more.

Remarks

InitNetwork() has to be called before using this command.

On Linux, 'libcurl' needs to be installed to have this command working (most of Linux distributions comes with it already installed).

Example

  InitNetwork()

  Header$ = GetHTTPHeader("http://www.purebasic.com/index.php")

  Repeat
    Index+1
    Line$ = StringField(Header$, Index, #LF$)
    Debug Line$
  Until Line$ = ""
Example of returned headers:
  HTTP/1.1 200 OK
  Date: Fri, 21 Mar 2008 09:49:30 GMT
  Server: Apache/1.3.34 (Debian) mod_vhost_online/1.1 mod_fastcgi/2.4.2 mod_log_online/0.1
  X-Powered-By: PHP/4.4.8-1
  Content-Type: text/html

See Also

ReceiveHTTPFile(), URLEncoder()

Supported OS

All

<- FinishHTTP() - Http Index - GetURLPart() ->