| ... | @@ -521,7 +521,7 @@ pub const Response = struct { | ... | @@ -521,7 +521,7 @@ pub const Response = struct { |
| 521 | | 521 | |
| 522 | /// A HTTP request that has been sent. | 522 | /// A HTTP request that has been sent. |
| 523 | /// | 523 | /// |
| 524 | /// Order of operations: request -> start[ -> write -> finish] -> wait -> read | 524 | /// Order of operations: open -> send[ -> write -> finish] -> wait -> read |
| 525 | pub const Request = struct { | 525 | pub const Request = struct { |
| 526 | uri: Uri, | 526 | uri: Uri, |
| 527 | client: *Client, | 527 | client: *Client, |
| ... | @@ -754,7 +754,7 @@ pub const Request = struct { | ... | @@ -754,7 +754,7 @@ pub const Request = struct { |
| 754 | /// If `handle_redirects` is true and the request has no payload, then this function will automatically follow | 754 | /// If `handle_redirects` is true and the request has no payload, then this function will automatically follow |
| 755 | /// redirects. If a request payload is present, then this function will error with error.RedirectRequiresResend. | 755 | /// redirects. If a request payload is present, then this function will error with error.RedirectRequiresResend. |
| 756 | /// | 756 | /// |
| 757 | /// Must be called after `start` and, if any data was written to the request body, then also after `finish`. | 757 | /// Must be called after `send` and, if any data was written to the request body, then also after `finish`. |
| 758 | pub fn wait(req: *Request) WaitError!void { | 758 | pub fn wait(req: *Request) WaitError!void { |
| 759 | while (true) { // handle redirects | 759 | while (true) { // handle redirects |
| 760 | while (true) { // read headers | 760 | while (true) { // read headers |
| ... | @@ -943,7 +943,7 @@ pub const Request = struct { | ... | @@ -943,7 +943,7 @@ pub const Request = struct { |
| 943 | } | 943 | } |
| 944 | | 944 | |
| 945 | /// Write `bytes` to the server. The `transfer_encoding` field determines how data will be sent. | 945 | /// Write `bytes` to the server. The `transfer_encoding` field determines how data will be sent. |
| 946 | /// Must be called after `start` and before `finish`. | 946 | /// Must be called after `send` and before `finish`. |
| 947 | pub fn write(req: *Request, bytes: []const u8) WriteError!usize { | 947 | pub fn write(req: *Request, bytes: []const u8) WriteError!usize { |
| 948 | switch (req.transfer_encoding) { | 948 | switch (req.transfer_encoding) { |
| 949 | .chunked => { | 949 | .chunked => { |
| ... | @@ -965,7 +965,7 @@ pub const Request = struct { | ... | @@ -965,7 +965,7 @@ pub const Request = struct { |
| 965 | } | 965 | } |
| 966 | | 966 | |
| 967 | /// Write `bytes` to the server. The `transfer_encoding` field determines how data will be sent. | 967 | /// Write `bytes` to the server. The `transfer_encoding` field determines how data will be sent. |
| 968 | /// Must be called after `start` and before `finish`. | 968 | /// Must be called after `send` and before `finish`. |
| 969 | pub fn writeAll(req: *Request, bytes: []const u8) WriteError!void { | 969 | pub fn writeAll(req: *Request, bytes: []const u8) WriteError!void { |
| 970 | var index: usize = 0; | 970 | var index: usize = 0; |
| 971 | while (index < bytes.len) { | 971 | while (index < bytes.len) { |
| ... | @@ -976,7 +976,7 @@ pub const Request = struct { | ... | @@ -976,7 +976,7 @@ pub const Request = struct { |
| 976 | pub const FinishError = WriteError || error{MessageNotCompleted}; | 976 | pub const FinishError = WriteError || error{MessageNotCompleted}; |
| 977 | | 977 | |
| 978 | /// Finish the body of a request. This notifies the server that you have no more data to send. | 978 | /// Finish the body of a request. This notifies the server that you have no more data to send. |
| 979 | /// Must be called after `start`. | 979 | /// Must be called after `send`. |
| 980 | pub fn finish(req: *Request) FinishError!void { | 980 | pub fn finish(req: *Request) FinishError!void { |
| 981 | switch (req.transfer_encoding) { | 981 | switch (req.transfer_encoding) { |
| 982 | .chunked => try req.connection.?.writer().writeAll("0\r\n\r\n"), | 982 | .chunked => try req.connection.?.writer().writeAll("0\r\n\r\n"), |
| ... | @@ -1308,7 +1308,7 @@ pub fn connectTunnel( | ... | @@ -1308,7 +1308,7 @@ pub fn connectTunnel( |
| 1308 | }; | 1308 | }; |
| 1309 | } | 1309 | } |
| 1310 | | 1310 | |
| 1311 | // Prevents a dependency loop in request() | 1311 | // Prevents a dependency loop in open() |
| 1312 | const ConnectErrorPartial = ConnectTcpError || error{ UnsupportedUrlScheme, ConnectionRefused }; | 1312 | const ConnectErrorPartial = ConnectTcpError || error{ UnsupportedUrlScheme, ConnectionRefused }; |
| 1313 | pub const ConnectError = ConnectErrorPartial || RequestError; | 1313 | pub const ConnectError = ConnectErrorPartial || RequestError; |
| 1314 | | 1314 | |