Mercurial > hg > orthanc
comparison Core/HttpServer/HttpOutput.cpp @ 1832:b7da58699f92
Fix formatting of multipart HTTP answers
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 26 Nov 2015 19:09:15 +0100 |
parents | 1558b3226b18 |
children | aa95aea0a352 |
comparison
equal
deleted
inserted
replaced
1831:3ae2ff249675 | 1832:b7da58699f92 |
---|---|
449 } | 449 } |
450 | 450 |
451 | 451 |
452 void HttpOutput::StateMachine::SendMultipartItem(const void* item, size_t length) | 452 void HttpOutput::StateMachine::SendMultipartItem(const void* item, size_t length) |
453 { | 453 { |
454 std::string header = "--" + multipartBoundary_ + "\n"; | 454 std::string header = "--" + multipartBoundary_ + "\r\n"; |
455 header += "Content-Type: " + multipartContentType_ + "\n"; | 455 header += "Content-Type: " + multipartContentType_ + "\r\n"; |
456 header += "Content-Length: " + boost::lexical_cast<std::string>(length) + "\n"; | 456 header += "Content-Length: " + boost::lexical_cast<std::string>(length) + "\r\n"; |
457 header += "MIME-Version: 1.0\n\n"; | 457 header += "MIME-Version: 1.0\r\n\r\n"; |
458 | 458 |
459 stream_.Send(false, header.c_str(), header.size()); | 459 stream_.Send(false, header.c_str(), header.size()); |
460 | 460 |
461 if (length > 0) | 461 if (length > 0) |
462 { | 462 { |
463 stream_.Send(false, item, length); | 463 stream_.Send(false, item, length); |
464 } | 464 } |
465 | 465 |
466 stream_.Send(false, "\n", 1); | 466 stream_.Send(false, "\r\n", 1); |
467 } | 467 } |
468 | 468 |
469 | 469 |
470 void HttpOutput::StateMachine::CloseMultipart() | 470 void HttpOutput::StateMachine::CloseMultipart() |
471 { | 471 { |
476 | 476 |
477 // The two lines below might throw an exception, if the client has | 477 // The two lines below might throw an exception, if the client has |
478 // closed the connection. Such an error is ignored. | 478 // closed the connection. Such an error is ignored. |
479 try | 479 try |
480 { | 480 { |
481 std::string header = "--" + multipartBoundary_ + "--\n"; | 481 std::string header = "--" + multipartBoundary_ + "--\r\n"; |
482 stream_.Send(false, header.c_str(), header.size()); | 482 stream_.Send(false, header.c_str(), header.size()); |
483 } | 483 } |
484 catch (OrthancException&) | 484 catch (OrthancException&) |
485 { | 485 { |
486 } | 486 } |