Giter Club home page Giter Club logo

Comments (10)

NghiaTranUIT avatar NghiaTranUIT commented on June 13, 2024

So, I investigate further by writing a dead simple Proxy by NodeJS.

It turns out, connect-proxy returns the Content-Length: 0 in the HTTP/1.1 200 OK message (code), so Android Emulator doesn't work 🤔

cURL or modern network client (URLSession, Web browsers) works fine, but not Android Emulator.

For example: cURL ignores it.

< HTTP/1.1 200 Connection Established
< Content-Length: 0
* Ignoring Content-Length in CONNECT 200 response

Question:

  1. Is it possible to completely remove the Content-Length: 0 or Transfer-Encoding: chunked ? I just want to return the simple message HTTP/1.1 200 OK from the CONNECT request.

from swift-nio-examples.

Lukasa avatar Lukasa commented on June 13, 2024

Yeah, good catch. Right now NIO doesn't support doing that, but it should. It's a somewhat complex patch to write though. Let me see if I can throw it together.

from swift-nio-examples.

NghiaTranUIT avatar NghiaTranUIT commented on June 13, 2024

Thanks. I finally write a patched version of HTTPResponseEncoder. It removed the Content-Length, and Transfer-Encoding logic. In the end, It fixes the bug.

Not sure if there are any unseen problems? 🤔

from swift-nio-examples.

Lukasa avatar Lukasa commented on June 13, 2024

The problems are in the general use-case: it isn't safe for us to unconditionally omit them, because users rely on our behaviour of inserting them. The trick is that we only want to skip that logic for responses to CONNECT requests. Fortunately, I believe we have the hooks we need to do this.

from swift-nio-examples.

Lukasa avatar Lukasa commented on June 13, 2024

Oof, actually it's quite hard to do it nicely. I think we need to add configuration to the encoders to enable you to opt-out of them modifying the framing headers.

from swift-nio-examples.

NghiaTranUIT avatar NghiaTranUIT commented on June 13, 2024

Thanks. I will keep on eyes on it, and report if it has any problems on production build 👍

from swift-nio-examples.

Lukasa avatar Lukasa commented on June 13, 2024

See apple/swift-nio#2508.

from swift-nio-examples.

Lukasa avatar Lukasa commented on June 13, 2024

I just merged that patch to main, want to try to use it?

from swift-nio-examples.

NghiaTranUIT avatar NghiaTranUIT commented on June 13, 2024

Thanks so much for your work @Lukasa I'm going to try it now 👍

from swift-nio-examples.

NghiaTranUIT avatar NghiaTranUIT commented on June 13, 2024

It works as intended. I'm happy to close this ticket 🙇

from swift-nio-examples.

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.