MCPcopy Create free account
hub / github.com/ClassiCube/ClassiCube / HttpClient_ParseHeader

Function HttpClient_ParseHeader

src/Http_Worker.c:414–431  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

412
413
414static 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 */
434static cc_bool HttpClient_HasBody(struct HttpRequest* req) {

Callers 1

HttpClient_ProcessFunction · 0.85

Calls 4

String_CaselessStartsFunction · 0.85
String_UNSAFE_SeparateFunction · 0.85
String_CopyFunction · 0.85

Tested by

no test coverage detected