comparison Core/HttpServer/HttpOutput.cpp @ 1523:c388502a066d

testing FilesystemHttpSender
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 11 Aug 2015 16:09:00 +0200
parents f938f7779bcb
children 9c5d93510414
comparison
equal deleted inserted replaced
1522:f938f7779bcb 1523:c388502a066d
500 } 500 }
501 501
502 502
503 void HttpOutput::Answer(IHttpStreamAnswer& stream) 503 void HttpOutput::Answer(IHttpStreamAnswer& stream)
504 { 504 {
505 HttpCompression compression = stream.SetupHttpCompression(isGzipAllowed_, isDeflateAllowed_);
506
507 switch (compression)
508 {
509 case HttpCompression_None:
510 break;
511
512 case HttpCompression_Gzip:
513 stateMachine_.AddHeader("Content-Encoding", "gzip");
514 break;
515
516 case HttpCompression_Deflate:
517 stateMachine_.AddHeader("Content-Encoding", "deflate");
518 break;
519
520 default:
521 throw OrthancException(ErrorCode_ParameterOutOfRange);
522 }
523
505 stateMachine_.SetContentLength(stream.GetContentLength()); 524 stateMachine_.SetContentLength(stream.GetContentLength());
506 525
507 std::string contentType = stream.GetContentType(); 526 std::string contentType = stream.GetContentType();
508 if (contentType.empty()) 527 if (contentType.empty())
509 { 528 {
516 if (stream.HasContentFilename(filename)) 535 if (stream.HasContentFilename(filename))
517 { 536 {
518 SetContentFilename(filename.c_str()); 537 SetContentFilename(filename.c_str());
519 } 538 }
520 539
521 HttpCompression compression = stream.GetHttpCompression(isGzipAllowed_, isDeflateAllowed_);
522
523 switch (compression)
524 {
525 case HttpCompression_None:
526 break;
527
528 case HttpCompression_Gzip:
529 stateMachine_.AddHeader("Content-Encoding", "gzip");
530 break;
531
532 case HttpCompression_Deflate:
533 stateMachine_.AddHeader("Content-Encoding", "deflate");
534 break;
535
536 default:
537 throw OrthancException(ErrorCode_ParameterOutOfRange);
538 }
539
540 while (stream.ReadNextChunk()) 540 while (stream.ReadNextChunk())
541 { 541 {
542 stateMachine_.SendBody(stream.GetChunkContent(), 542 stateMachine_.SendBody(stream.GetChunkContent(),
543 stream.GetChunkSize()); 543 stream.GetChunkSize());
544 } 544 }