1
Fork 0
hare-http/net/http/request.ha

36 lines
1.1 KiB
Hare
Raw Normal View History

2023-02-09 19:54:21 +00:00
use io;
use net::uri;
// Stores state related to an HTTP request.
//
// For a request to be processable by an HTTP [[client]], i.e. via [[do]], the
// method and target must be filled in appropriately. The target must include at
// least a host, port, and scheme. The default values for other fields are
// suitable if appropriate for the request you wish to perform.
2023-02-09 19:54:21 +00:00
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, or void if there is no body.
2023-02-09 19:54:21 +00:00
body: (io::handle | void),
};
2023-02-09 22:23:05 +00:00
// Frees state associated with an HTTP [[request]].
export fn request_finish(req: *request) void = {
2023-02-10 09:13:30 +00:00
header_free(&req.header);
2023-02-09 22:23:05 +00:00
uri::finish(req.target);
free(req.target);
};