| 577 | } |
| 578 | |
| 579 | bool MergeChunkedResponse (std::istream& in, std::ostream& out) |
| 580 | { |
| 581 | std::string hexLen; |
| 582 | while (!in.eof ()) |
| 583 | { |
| 584 | std::getline (in, hexLen); |
| 585 | errno = 0; |
| 586 | long int len = strtoul(hexLen.c_str(), (char **) NULL, 16); |
| 587 | if (errno != 0) |
| 588 | return false; /* conversion error */ |
| 589 | if (len == 0) |
| 590 | return true; /* end of stream */ |
| 591 | if (len < 0 || len > 10 * 1024 * 1024) /* < 10Mb */ |
| 592 | return false; /* too large chunk */ |
| 593 | char * buf = new char[len]; |
| 594 | in.read (buf, len); |
| 595 | out.write (buf, len); |
| 596 | delete[] buf; |
| 597 | std::getline (in, hexLen); // read \r\n after chunk |
| 598 | } |
| 599 | return true; |
| 600 | } |
| 601 | |
| 602 | std::string CreateBasicAuthorizationString (const std::string& user, const std::string& pass) |
| 603 | { |