| 412 | |
| 413 | |
| 414 | static void HttpClient_ParseHeader(struct HttpClientState* state, const cc_string* line) { |
| 415 | static const cc_string HTTP_10_VERSION = String_FromConst("HTTP/1.0"); |
| 416 | cc_string name, value; |
| 417 | /* HTTP 1.0 defaults to auto closing connection */ |
| 418 | if (String_CaselessStarts(line, &HTTP_10_VERSION)) state->autoClose = true; |
| 419 | |
| 420 | /* name: value */ |
| 421 | if (!String_UNSAFE_Separate(line, ':', &name, &value)) return; |
| 422 | |
| 423 | if (String_CaselessEqualsConst(&name, "Transfer-Encoding")) { |
| 424 | state->chunked = String_CaselessEqualsConst(&value, "chunked"); |
| 425 | } else if (String_CaselessEqualsConst(&name, "Location")) { |
| 426 | String_Copy(&state->location, &value); |
| 427 | } else if (String_CaselessEqualsConst(&name, "Connection")) { |
| 428 | if (String_CaselessEqualsConst(&value, "keep-alive")) state->autoClose = false; |
| 429 | if (String_CaselessEqualsConst(&value, "close")) state->autoClose = true; |
| 430 | } |
| 431 | } |
| 432 | |
| 433 | /* RFC 7230, section 3.3.3 - Message Body Length */ |
| 434 | static cc_bool HttpClient_HasBody(struct HttpRequest* req) { |
no test coverage detected