Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting errors with compression set to true #83

Closed
QiMata opened this issue Mar 8, 2016 · 2 comments
Closed

Getting errors with compression set to true #83

QiMata opened this issue Mar 8, 2016 · 2 comments

Comments

@QiMata
Copy link

QiMata commented Mar 8, 2016

The offending class is in ZLibServerFilter.h and the offending line is in the sendHeaders method:

void sendHeaders(HTTPMessage& msg) noexcept override {
    DCHECK(compressor_ == nullptr);
    DCHECK(header_ == false); //This is the offending line

    chunked_ = msg.getIsChunked();

    // Make final determination of whether to compress
    compress_ = isCompressibleContentType(msg) &&
      (chunked_ || isMinimumCompressibleSize(msg));

    // Add the gzip header
    if (compress_) {
      auto& headers = msg.getHeaders();
      headers.set(HTTP_HEADER_CONTENT_ENCODING, "gzip");
    }

    // If it's chunked or not being compressed then the headers can be sent
    // if it's compressed and one body, then need to calculate content length.
    if (chunked_ || !compress_) {
      Filter::sendHeaders(msg);
      header_ = true;
    } else {
      responseMessage_ = folly::make_unique<HTTPMessage>(msg);
    }
  }

This is the code for my onEOM method:

void whod::server::file_server::file_handler::onEOM() noexcept
{
    if (file_container_->contains(path_))
    {
        ResponseBuilder(downstream_)
                .status(200, "OK")
                .body(file_container_->get(path_))
                .sendWithEOM();
    }
    ResponseBuilder(downstream_)
            .status(404, "NOT FOUND")
            .body(file_container_->get("/404.html"))
            .sendWithEOM();
}

the stack trace:
F0308 09:19:55.967344 12264 ZlibServerFilter.h:39] Check failed: header_ == false
*** Check failure stack trace: ***
@ 0x7f097fd47daa (unknown)
@ 0x7f097fd47ce4 (unknown)
@ 0x7f097fd476e6 (unknown)
@ 0x7f097fd4a687 (unknown)
@ 0x7f09806d6709 proxygen::ZlibServerFilter::sendHeaders()
@ 0x44cd29 proxygen::ResponseBuilder::send()
@ 0x44cb62 proxygen::ResponseBuilder::sendWithEOM()
@ 0x44bca3 whod::server::file_server::file_handler::onEOM()
@ 0x7f0980718583 proxygen::HTTPTransaction::processIngressEOM()
@ 0x7f098071991d proxygen::HTTPTransaction::onIngressEOM()
@ 0x7f098070c26f proxygen::HTTPSession::onMessageComplete()
@ 0x7f098073c2e5 proxygen::HTTP1xCodec::onMessageComplete()
@ 0x7f098073d44a proxygen::HTTP1xCodec::onMessageCompleteCB()
@ 0x7f09806ffe80 proxygen::http_parser_execute()
@ 0x7f098073c919 proxygen::HTTP1xCodec::onIngress()
@ 0x7f0980704b67 proxygen::HTTPSession::processReadData()
@ 0x7f0980706645 proxygen::HTTPSession::readDataAvailable()
@ 0x7f0980145180 folly::AsyncSocket::handleRead()
@ 0x7f0980141edb folly::AsyncSocket::ioReady()
@ 0x7f097d7ccf24 (unknown)
@ 0x7f09801537ee folly::EventBase::loopBody()
@ 0x7f0980154a84 folly::EventBase::loopForever()
@ 0x7f0980787cef wangle::IOThreadPoolExecutor::threadRun()
@ 0x7f098079ad83 ZNKSt7_Mem_fnIMN6wangle18ThreadPoolExecutorEFvSt10shared_ptrINS1_6ThreadEEEEclIJRS4_EvEEvPS1_DpOT
@ 0x7f098079960d _ZNSt5_BindIFSt7_Mem_fnIMN6wangle18ThreadPoolExecutorEFvSt10shared_ptrINS2_6ThreadEEEEPS2_S5_EE6__callIvIEILm0ELm1EEEET_OSt5tupleIIDpT0_EESt12_Index_tupleIIXspT1_EEE
@ 0x7f0980796f88 std::_Bind<>::operator()<>()
@ 0x7f0980794d93 std::_Function_handler<>::_M_invoke()
@ 0x7f097f8c4a60 (unknown)
@ 0x7f097f3e7182 start_thread
@ 0x7f097f11438d (unknown)
@ (nil) (unknown)

@crackcomm
Copy link

I think it's because You send response twice, try with else:

void whod::server::file_server::file_handler::onEOM() noexcept {
    if (file_container_->contains(path_)) {
        ResponseBuilder(downstream_)
                .status(200, "OK")
                .body(file_container_->get(path_))
                .sendWithEOM();
    } else {
        ResponseBuilder(downstream_)
                .status(404, "NOT FOUND")
                .body(file_container_->get("/404.html"))
                .sendWithEOM();
    }
}

@QiMata
Copy link
Author

QiMata commented Mar 8, 2016

You are right, and I feel dumb. Thank you!

@QiMata QiMata closed this as completed Mar 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants