| ... | ... | @@ -821,13 +821,15 @@ pub const Request = struct { |
| 821 | 821 | if (req.handle_continue) |
| 822 | 822 | continue; |
| 823 | 823 | |
| 824 | | break; |
| 824 | return; // we're not handling the 100-continue, return to the caller |
| 825 | 825 | } |
| 826 | 826 | |
| 827 | 827 | // we're switching protocols, so this connection is no longer doing http |
| 828 | | if (req.response.status == .switching_protocols or (req.method == .CONNECT and req.response.status == .ok)) { |
| 828 | if (req.method == .CONNECT and req.response.status.class() == .success) { |
| 829 | 829 | req.connection.?.closing = false; |
| 830 | 830 | req.response.parser.done = true; |
| 831 | |
| 832 | return; // the connection is not HTTP past this point, return to the caller |
| 831 | 833 | } |
| 832 | 834 | |
| 833 | 835 | // we default to using keep-alive if not provided in the client if the server asks for it |
| ... | ... | @@ -842,6 +844,15 @@ pub const Request = struct { |
| 842 | 844 | req.connection.?.closing = true; |
| 843 | 845 | } |
| 844 | 846 | |
| 847 | // Any response to a HEAD request and any response with a 1xx (Informational), 204 (No Content), or 304 (Not Modified) |
| 848 | // status code is always terminated by the first empty line after the header fields, regardless of the header fields |
| 849 | // present in the message |
| 850 | if (req.method == .HEAD or req.response.status.class() == .informational or req.response.status == .no_content or req.response.status == .not_modified) { |
| 851 | req.response.parser.done = true; |
| 852 | |
| 853 | return; // the response is empty, no further setup or redirection is necessary |
| 854 | } |
| 855 | |
| 845 | 856 | if (req.response.transfer_encoding != .none) { |
| 846 | 857 | switch (req.response.transfer_encoding) { |
| 847 | 858 | .none => unreachable, |
| ... | ... | @@ -855,12 +866,8 @@ pub const Request = struct { |
| 855 | 866 | |
| 856 | 867 | if (cl == 0) req.response.parser.done = true; |
| 857 | 868 | } else { |
| 858 | | req.response.parser.done = true; |
| 859 | | } |
| 860 | | |
| 861 | | // HEAD requests have no body |
| 862 | | if (req.method == .HEAD) { |
| 863 | | req.response.parser.done = true; |
| 869 | // read until the connection is closed |
| 870 | req.response.parser.next_chunk_length = std.math.maxInt(u64); |
| 864 | 871 | } |
| 865 | 872 | |
| 866 | 873 | if (req.response.status.class() == .redirect and req.handle_redirects) { |