Merge _set_content_length into new_request_body
This commit is contained in:
parent
5038e0031a
commit
337d063f15
|
@ -91,21 +91,18 @@ fn new_request_body(
|
|||
) request = {
|
||||
let req = new_request(client, method, target);
|
||||
req.body = body;
|
||||
request_set_content_length(&req, body);
|
||||
return req;
|
||||
};
|
||||
|
||||
fn request_set_content_length(req: *request, body: io::handle) void = {
|
||||
const prev = match (io::seek(body, 0, io::whence::CUR)) {
|
||||
const offs = match (io::seek(body, 0, io::whence::CUR)) {
|
||||
case let off: io::off =>
|
||||
yield off;
|
||||
case io::error =>
|
||||
header_add(&req.header, "Transfer-Encoding", "chunked");
|
||||
return;
|
||||
return req;
|
||||
};
|
||||
const ln = io::seek(body, 0, io::whence::END)!;
|
||||
io::seek(body, prev, io::whence::SET)!;
|
||||
io::seek(body, offs, io::whence::SET)!;
|
||||
header_add(&req.header, "Content-Length", strconv::ztos(ln: size));
|
||||
return req;
|
||||
};
|
||||
|
||||
fn uri_origin_form(target: *uri::uri) uri::uri = {
|
||||
|
|
Loading…
Reference in a new issue