| 382 | } |
| 383 | |
| 384 | static dmSocket::Result SendAll(Response* response, const char* buffer, int length) |
| 385 | { |
| 386 | int total_sent_bytes = 0; |
| 387 | int sent_bytes = 0; |
| 388 | |
| 389 | while (total_sent_bytes < length) { |
| 390 | dmSocket::Result r; |
| 391 | if (response->m_SSLSocket) |
| 392 | r = dmSSLSocket::Send(response->m_SSLSocket, buffer + total_sent_bytes, length - total_sent_bytes, &sent_bytes); |
| 393 | else |
| 394 | r = dmSocket::Send(response->m_Socket, buffer + total_sent_bytes, length - total_sent_bytes, &sent_bytes); |
| 395 | |
| 396 | if( r == dmSocket::RESULT_WOULDBLOCK ) |
| 397 | { |
| 398 | r = dmSocket::RESULT_TRY_AGAIN; |
| 399 | } |
| 400 | if( (r == dmSocket::RESULT_OK || r == dmSocket::RESULT_TRY_AGAIN) && HasRequestTimedOut(response->m_Client) ) |
| 401 | { |
| 402 | r = dmSocket::RESULT_WOULDBLOCK; |
| 403 | } |
| 404 | |
| 405 | if (r == dmSocket::RESULT_TRY_AGAIN) |
| 406 | continue; |
| 407 | |
| 408 | if (r != dmSocket::RESULT_OK) { |
| 409 | return r; |
| 410 | } |
| 411 | |
| 412 | total_sent_bytes += sent_bytes; |
| 413 | } |
| 414 | return dmSocket::RESULT_OK; |
| 415 | } |
| 416 | |
| 417 | static dmSocket::Result Receive(Response* response, void* buffer, int length, int* received_bytes) |
| 418 | { |
no test coverage detected