| 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) \ |
| 600 | sock_res = SendAll(response, s, strlen(s));\ |