Commit 0d140aa9f672b0ab42145a21576159acd450820d

Authored by Matti Virkkunen
1 parent 80a7f247

Make HTTP header parsing case-insensitive

libpurple/linehttptransport.cpp
  1 +#include <algorithm>
1 2 #include <sstream>
2 3 #include <limits>
3 4  
... ... @@ -374,19 +375,22 @@ void LineHttpTransport::try_parse_response_header() {
374 375 std::string name, value;
375 376  
376 377 std::getline(stream, name, ':');
  378 + std::transform(name.begin(), name.end(), name.begin(), tolower);
  379 +
377 380 stream.ignore(256, ' ');
378 381  
379   - if (name == "Content-Length")
  382 + if (name == "content-length")
380 383 stream >> content_length_;
381 384  
382   - if (name == "X-LS")
  385 + if (name == "x-ls")
383 386 std::getline(stream, x_ls, '\r');
384 387  
385   - if (name == "Connection") {
  388 + if (name == "connection") {
386 389 std::string value;
387 390 std::getline(stream, value, '\r');
  391 + std::transform(value.begin(), value.end(), value.begin(), tolower);
388 392  
389   - if (value == "Keep-Alive" || value == "Keep-alive" || value == "keep-alive")
  393 + if (value == "keep-alive")
390 394 keep_alive = true;
391 395 }
392 396  
... ...