MCPcopy Create free account
hub / github.com/defold/defold / WriteHeader

Function WriteHeader

engine/dlib/src/dlib/http_client.cpp:576–597  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

574 }
575
576 Result WriteHeader(HResponse response, const char* name, const char* value)
577 {
578 HClient client = response->m_Client;
579 if (client->m_SocketResult != dmSocket::RESULT_OK) {
580 return RESULT_SOCKET_ERROR;
581 }
582 dmSocket::Result sock_res;
583
584 // DEF-2889 most webservers have a header length limit of 8096 bytes
585 char buf[8096];
586 const int bufsize = sizeof(buf);
587 if(dmSnPrintf(buf, bufsize, "%s: %s\r\n", name, value) == -1) {
588 dmLogWarning("Truncated HTTP request header %s since it was larger than %d", name, bufsize);
589 }
590
591 sock_res = SendAll(response, buf, strlen(buf));
592 if (sock_res != dmSocket::RESULT_OK) {
593 client->m_SocketResult = sock_res;
594 return RESULT_SOCKET_ERROR;
595 }
596 return RESULT_OK;
597 }
598
599#define HTTP_CLIENT_SENDALL_AND_BAIL(s) \
600sock_res = SendAll(response, s, strlen(s));\

Callers 3

HttpWriteHeadersFunction · 0.85
HttpWriteHeadersMethod · 0.85
HttpWriteHeadersFunction · 0.85

Calls 2

dmSnPrintfFunction · 0.85
SendAllFunction · 0.70

Tested by 1

HttpWriteHeadersMethod · 0.68