Comments (10)
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:
- Is it possible to completely remove the
Content-Length: 0
orTransfer-Encoding: chunked
? I just want to return the simple messageHTTP/1.1 200 OK
from the CONNECT request.
from swift-nio-examples.
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.
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.
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.
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.
Thanks. I will keep on eyes on it, and report if it has any problems on production build 👍
from swift-nio-examples.
See apple/swift-nio#2508.
from swift-nio-examples.
I just merged that patch to main
, want to try to use it?
from swift-nio-examples.
Thanks so much for your work @Lukasa I'm going to try it now 👍
from swift-nio-examples.
It works as intended. I'm happy to close this ticket 🙇
from swift-nio-examples.
Related Issues (20)
- http2-client should use ALPNHandler
- http2-client should suppress uncleanShutdown errors
- Document why SMTPResponseDecoder uses ChannelInboundHandler
- NIOSMTP should support STARTTLS HOT 2
- the JSONRPC example codecs should move into swift-nio-extras
- should publish API docs HOT 2
- NIOSMTP: should implement escaping
- TCPClient in json-rpc isn't thread-safe HOT 2
- json-rpc: license headers missing
- connect-proxy is missing a README HOT 1
- Using JSONRPC codecs in another project HOT 2
- nio-connect-proxy fails to send error response HOT 2
- build swift-nio-example failed get error, memory file not found HOT 1
- connect-proxy example isn't working with DNS Over HTTPS HOT 11
- Example of JSON RPC using blocking semantics? HOT 6
- proper HTTP server example
- http2-client fatally fails with IP address URLs HOT 1
- http2-client fatally fails when connection is refused HOT 2
- connect-proxy demo access http resource return 'Invalid HTTP message type get' HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swift-nio-examples.