1
Fork 0
hare-http/net/http/request.ha
2023-02-12 12:55:16 +01:00

31 lines
776 B
Hare

use io;
use net::uri;
// Stores state related to an HTTP request.
export type request = struct {
// HTTP request method, e.g. GET
method: str,
// Request target URI.
//
// Note that the normal constraints for [[uri::parse]] are not upheld in
// the case of a request using the origin-form (e.g. /index.html), i.e.
// the scheme field may be empty.
target: *uri::uri,
// List of HTTP request headers.
header: header,
// Transport configuration, or null to use the [[client]] default.
transport: nullable *transport,
// I/O reader for the request body.
body: (io::handle | void),
};
// Frees state associated with an HTTP [[request]].
export fn request_finish(req: *request) void = {
header_free(&req.header);
uri::finish(req.target);
free(req.target);
};