public class HttpRequest extends Object:
Immutable HTTP request description.
HttpRequest carries the URL, method, headers and optional body to be sent by HttpClient.
import klyn.net
request = HttpRequest("https://example.com/api", "POST").withBody({"name": "klyn"})
print(request.method)| Modifier and Type | Member | Description |
|---|---|---|
| public readonly property | bodybody as Object: |
Optional request body. |
| public readonly property | headers | Request headers copied at construction time. |
| public readonly property | methodmethod as String: |
Normalized HTTP method. |
| public readonly property | urlurl as URL: |
Target HTTP or HTTPS URL. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | HttpRequest | Creates an immutable HTTP request. |
| Modifier and Type | Member | Description |
|---|---|---|
| public override | toStringtoString() as String: |
No summary. |
| public | withBodywithBody(body as Object) as HttpRequest throws Exception: |
Returns a copy with a different request body. |
| public | withHeaderwithHeader(name as String, value as String) as HttpRequest throws Exception: |
Returns a copy with one header added or replaced. |
| public | withMethodwithMethod(method as String) as HttpRequest throws Exception: |
Returns a copy with a different HTTP method. |
| public | withoutHeaderwithoutHeader(name as String) as HttpRequest throws Exception: |
Returns a copy without one header. |