diff options
Diffstat (limited to 'linden/indra/llmessage/llurlrequest.cpp')
-rw-r--r-- | linden/indra/llmessage/llurlrequest.cpp | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/linden/indra/llmessage/llurlrequest.cpp b/linden/indra/llmessage/llurlrequest.cpp index fbd002b..ee62798 100644 --- a/linden/indra/llmessage/llurlrequest.cpp +++ b/linden/indra/llmessage/llurlrequest.cpp | |||
@@ -484,27 +484,29 @@ static size_t headerCallback(void* data, size_t size, size_t nmemb, void* user) | |||
484 | // Per HTTP spec the first header line must be the status line. | 484 | // Per HTTP spec the first header line must be the status line. |
485 | if (!complete->haveHTTPStatus()) | 485 | if (!complete->haveHTTPStatus()) |
486 | { | 486 | { |
487 | std::string::iterator end = header.end(); | 487 | if (header.substr(0,5) == "HTTP/") |
488 | std::string::iterator pos1 = std::find(header.begin(), end, ' '); | ||
489 | if (pos1 != end) ++pos1; | ||
490 | std::string::iterator pos2 = std::find(pos1, end, ' '); | ||
491 | if (pos2 != end) ++pos2; | ||
492 | std::string::iterator pos3 = std::find(pos2, end, '\r'); | ||
493 | |||
494 | std::string version(header.begin(), pos1); | ||
495 | std::string status(pos1, pos2); | ||
496 | std::string reason(pos2, pos3); | ||
497 | |||
498 | int statusCode = atoi(status.c_str()); | ||
499 | if (statusCode > 0) | ||
500 | { | 488 | { |
501 | complete->httpStatus((U32)statusCode, reason); | 489 | std::string::iterator end = header.end(); |
502 | } | 490 | std::string::iterator pos1 = std::find(header.begin(), end, ' '); |
503 | else | 491 | if (pos1 != end) ++pos1; |
504 | { | 492 | std::string::iterator pos2 = std::find(pos1, end, ' '); |
505 | llwarns << "Unable to parse http response status line: " | 493 | if (pos2 != end) ++pos2; |
506 | << header << llendl; | 494 | std::string::iterator pos3 = std::find(pos2, end, '\r'); |
507 | complete->httpStatus(499,"Unable to parse status line."); | 495 | |
496 | std::string version(header.begin(), pos1); | ||
497 | std::string status(pos1, pos2); | ||
498 | std::string reason(pos2, pos3); | ||
499 | |||
500 | int statusCode = atoi(status.c_str()); | ||
501 | if (statusCode >= 300 && statusCode < 400) | ||
502 | { | ||
503 | // This is a redirect, ignore it and all headers | ||
504 | // until we find a normal status code. | ||
505 | } | ||
506 | else if (statusCode > 0) | ||
507 | { | ||
508 | complete->httpStatus((U32)statusCode, reason); | ||
509 | } | ||
508 | } | 510 | } |
509 | return header_len; | 511 | return header_len; |
510 | } | 512 | } |