Comments (1)
I can confirm this error. Here are three examples using your subclass:
l = Coolio::Loop.default
msn = MyHttp.connect("www.msn.com").attach(l)
msn.request("GET", '/')
l.run
This prints "HTTP FINISHED". The response_header contains a "content-length" header (and no "transfer-encoding: chunked" header).
l = Coolio::Loop.default
ip = MyHttp.connect("jsonip.com).attach(l)
ip.request("GET", '/')
l.run
This too prints "HTTP FINISHED". There is a "transfer-encoding: chunked" header present (but no "content-length" header).
Finally, trying your "www.google.com" example does not print "HTTP FINISHED", i.e.: on_request_complete is not called. And both those headers are not defined.
I think this problem can be traced to the following source from Coolio::HttpClient#process_body (cool.io/http_client.rb):
if @bytes_remaining.nil?
on_body_data @data.read
return false
end
This code is evaluated if and only if the server has not set both the "Transfer-Encoding: chunked" header and the "Content-Length" header since Coolio::HttpClient sets @bytes_remaining to nil. Hence, @State is never changed from :body to :finished and on_request_complete never gets called.
One work around would be to set a callback that calls on_request_complete whenever the server closes the TCP connection and those two HTTP headers are unset. I'm not entirely sure about the correct way to do this with the Coolio API though.
Would you define HttpClient#on_close? If so, how?
from cool.io.
Related Issues (20)
- JRuby support HOT 7
- Easier HTTP client for cool.io? HOT 4
- Fiber-aware deferred operation HOT 4
- windows ruby1.8.7 support HOT 1
- More fine GVL release span HOT 2
- Question HOT 1
- CPU100% on Windows Server 2012 HOT 20
- JRuby support again HOT 5
- Remove Cool.io::HttpClient HOT 1
- Remove cool.io/eventmachine.rb HOT 1
- Thread#join using coolio makes a process down on Windows. HOT 3
- Example Program in README.md not worked. HOT 5
- Investigate "expected loop to be an instance of Coolio::Loop" error HOT 2
- Change FT_SETSIZE on Windows HOT 1
- Cool.io::TCPServer continues to receive data even if its close method is called HOT 3
- Could not install when using Ruby 2.5 (x64-mingw32) HOT 2
- Use github.io instead of github.com on description HOT 1
- Two test failures with IPv6? HOT 1
- cool.io v1.7.1 fat gem doesn't include Ruby 3.0 binaries HOT 1
- cool.io is no longer buildable on Ruby 3.3.0-dev
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 cool.io.