Metadata-Version: 2.1
Name: polywrap-http-plugin
Version: 0.1.0b3
Summary: 
Author: Niraj
Author-email: niraj@polywrap.io
Requires-Python: >=3.10,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Dist: httpx (>=0.23.3,<0.24.0)
Requires-Dist: polywrap-core (>=0.1.0b3,<0.2.0)
Requires-Dist: polywrap-manifest (>=0.1.0b3,<0.2.0)
Requires-Dist: polywrap-msgpack (>=0.1.0b3,<0.2.0)
Requires-Dist: polywrap-plugin (>=0.1.0b3,<0.2.0)
Description-Content-Type: text/markdown

# polywrap-http-plugin

Http plugin currently supports two different methods `GET` and `POST`. Similar to calling axios, when defining request you need to specify a response type. Headers and query parameters may also be defined.

## Response Types

`TEXT` - The server will respond with text, the HTTP plugin will return the text as-is.

`BINARY` - The server will respond with binary data (_bytes_), the HTTP plugin will encode as a **base64** string and return it.

## GET request

Below is sample invocation of the `GET` request with custom request headers and query parameters (`urlParams`).

```python
result = client.invoke(
    uri="wrap://ens/http.polywrap.eth",
    method="get",
    args={
        "url": "http://www.example.com/api",
        "request": {
            "responseType": "TEXT",
            "urlParams": [{"key": "query", "value": "foo"}],
            "headers": [{"key": "X-Request-Header", "value": "req-foo"}],
        },
    },
)
```

## POST request

Below is sample invocation of the `POST` request with custom request headers and query parameters (`urlParams`). It is also possible to set request body as shown below.

```python
response = client.invoke(
    uri="wrap://ens/http.polywrap.eth",
    method="post",
    args={
        "url": "http://www.example.com/api",
        "request": {
            "responseType": "TEXT",
            "urlParams": [{"key": "query", "value": "foo"}],
            "headers": [{"key": "X-Request-Header", "value": "req-foo"}],
            "body": "{data: 'test-request'}",
        }
    }
)
```

