# http

The `http` statement initiates an HTTP session using any settings previously configured using the [set](/2.10.2/data-pipelines/extract/language/set.md) statement. It can also be used for querying response headers.

## Syntax

**`http`***`method url`*

**`http dump_headers`**

**`http get_header`***`headerName`***`as`***`varName`*

## Details

### Executing an HTTP request

The `http` statement performs an HTTP request against the server and resource specified in the *url* paramater. Any http-related settings previously configured using [set](/2.10.2/data-pipelines/extract/language/set.md) will be applied to the request.

The *method* argument determines the HTTP method to use for the request and must be one of `GET`, `PUT`, `POST` or `DELETE`.

The *url* argument must start with either `http:` or `https:`. If `https:` is used then SSL will be used for the request.

The *url* argument must also contain a valid IP address or hostname. Optionally, it may also contain a port number (preceded by a colon and appended to the IP address or hostname) and a resource.

The following defaults apply if no port or resource is specified:

| Field      | Default                                     |
| ---------- | ------------------------------------------- |
| *port*     | `80` if using `http` `443` if using `https` |
| *resource* | `/`                                         |

The format of the `http` statement is identical when used in conjunction with the [buffer](/2.10.2/data-pipelines/extract/language/buffer.md) statement.

### Querying response headers

To dump a list of all the response headers returned by the server in the most recent session use the statement:

**`http dump_headers`**

This will render a list of the headers to standard output, and is useful when implementing and debugging USE scripts. The intention of this statement is to provide a tool to assist in script development, and as such it would normally be removed or suppressed with a debug mode switch in production environments.

To retrieve the value of a specific header, use the statement:

**`http get_header`***`headerName`***`as`***`varName`*

This will set the variable *varName* to be the value of the header *headerName*.

{% hint style="info" %}
If *headerName* was not found in the response, then a warning will be written to the log-file. In this case *varName* will not be created but if it already exists then its original value will be unmodified.
{% endhint %}

## Examples

### Example 1

```
# A simple request using the default port and no SSL
set http_savefile "/extracted/http/customers.json"
http GET "http://localhost/v1/customers"

# A more complex request requiring setup and a custom port
clear http_headers
set http_header "Accept: application/json"
set http_header "Authorization: FFDC-4567-AE53-1234"    
set http_savefile "extracted/http/customers.json"
buffer customers = http GET "https://demo.server.com:4444/v1/customers"
```

### Example 2

The following shows the process of retrieving a header. The output of:

```
buffer temp = http GET https://www.google.com
http dump_headers
http get_header Date as responseDate
print The Date header from google.com was: ${responseDate}
```

Takes the following form:

```
Last response headers:
HTTP/1.1 200 OK
Cache-Control: private, max-age=0
Date: Mon, 26 Mar 2018 13:50:39 GMT
Transfer-Encoding: chunked
Content-Type: text/html; charset=ISO-8859-1
Expires: -1
Accept-Ranges: none
P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info."
Server: gws
Set-Cookie: 1P_JAR=2018-03-26-13; expires=Wed, 25-Apr-2018 13:50:39 GMT; path=/; domain=.google.co.uk
Set-Cookie: [redacted]; expires=Tue, 25-Sep-2018 13:50:39 GMT; path=/; domain=.google.co.uk; HttpOnly
Vary: Accept-Encoding
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
Alt-Svc: hq=":443"; ma=2592000; quic=51303432; quic=51303431; quic=51303339; quic=51303335,quic=":443"; ma=2592000; v="42,41,39,35"

The Date header from google.com was: Mon, 26 Mar 2018 13:50:39 GMT
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://olddocs.exivity.io/2.10.2/data-pipelines/extract/language/http.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
