Giter VIP home page Giter VIP logo

Comments (3)

SteveSelva avatar SteveSelva commented on September 21, 2024

Found the cause of the issue, and it was that the Proxygen is sending END_STREAM Flag separately in a empty DATA Frame, instead it can send it with the HEADERS Frame itself. Modified it to send END_STREAM Flag within the HEADERS Frame and the issue got resolved.

from proxygen.

afrind avatar afrind commented on September 21, 2024

Can you share a snippet of your code fix?

There's definitely some friction in proxies because the onHeadersComplete codec callback doesn't include the END_STREAM flag, so it can be challenging to immediately pass through to an upstream without making an assumption (eg: GET == END_STREAM) or delaying an event loop so the onEOM downstream callback fires.

I've even tried fixing this once, but ran into some complications.

from proxygen.

SteveSelva avatar SteveSelva commented on September 21, 2024

I don't know whether this approach is right or not. But somehow it works for now.

HTTP2Codec.cpp
Line No:520

if (!(curHeader_.flags & http2::END_STREAM)) {
  // If it there are DATA frames coming, consider it chunked
  msg->setIsChunked(true);
}

This code tells that if the stream ends or not. If it doesn't end the HTTPMessage is set to chunked.
So in ProxyHandler, I am checking whether the CodecProtocol is HTTP2 and HTTPMessage is not chunked, if both conditions satisfy, then sending the Upstream transaction with EOM using sendHeadersWithEOM().

ProxyHandler.cpp

if (txn_->getTransport().getHTTPSessionBase()->getCodecProtocol() == proxygen::CodecProtocol::HTTP_2 && 
downstream_->getTransaction()->getTransport().getHTTPSessionBase()->getCodecProtocol() == proxygen::CodecProtocol::HTTP_2 &&
 !request_->getIsChunked()) {
    txn_->sendHeadersWithEOM(*request_);
}
else {
    txn_->sendHeaders(*request_);
}

This code checks whether both Upstream and Downstream works in HTTP2 and then checks whether the message is chunked which in turn is true if END_STREAM is not set.

Please provide some insights on whether this approach is right or not.

from proxygen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.