HttpRequest
classin packageklyn.net
public class HttpRequest extends Object:
└ HttpRequest

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)
Properties
Modifier and Type Member Description
public readonly property body
body as Object:
Optional request body.
public readonly property headers
headers as Map<String, String>:
Request headers copied at construction time.
public readonly property method
method as String:
Normalized HTTP method.
public readonly property url
url as URL:
Target HTTP or HTTPS URL.
Properties inherited from Object: type
Constructors
Modifier and Type Member Description
public HttpRequest
HttpRequest(url as Object, method as String = "GET", headers as Map<String, String> = null, body as Object = null) throws Exception:
Creates an immutable HTTP request.
Methods
Modifier and Type Member Description
public override toString
toString() as String:
No summary.
public withBody
withBody(body as Object) as HttpRequest throws Exception:
Returns a copy with a different request body.
public withHeader
withHeader(name as String, value as String) as HttpRequest throws Exception:
Returns a copy with one header added or replaced.
public withMethod
withMethod(method as String) as HttpRequest throws Exception:
Returns a copy with a different HTTP method.
public withoutHeader
withoutHeader(name as String) as HttpRequest throws Exception:
Returns a copy without one header.
Methods inherited from Object: fromJson, toDict, toJson, toString, toXml