Comments (25)
@llorllale/z please, pay attention to this issue
from cactoos-http.
Job #74 is now in scope, role is DEV
from cactoos-http.
The job #74 assigned to @Umbrah/z, here is why; the budget is 30 minutes, see §4; please, read §8 and §9; if the task is not clear, read this and this; there will be no monetary reward for this job
from cactoos-http.
@0crat refuse
from cactoos-http.
@Umbrah The user @Umbrah/z resigned from #74, please stop working. Reason for job resignation: Order was cancelled
from cactoos-http.
Tasks refusal is discouraged, see §6: -15 point(s) just awarded to @Umbrah/z
from cactoos-http.
The job #74 assigned to @vzurauskas/z, here is why; the budget is 30 minutes, see §4; please, read §8 and §9; if the task is not clear, read this and this; there will be no monetary reward for this job
from cactoos-http.
from cactoos-http.
@vzurauskas The impediment for #74 was registered successfully by @vzurauskas/z
from cactoos-http.
@llorllale To understand this better, I created #84 But in addition to the more generic questions there, I have a few more related specifically to this task.
If user wants to perform a series of request-response exchanges with server while keeping connection alive, he would use a pattern similar to the example in this comment, where each request could reuse the same HtKeepAliveWire
. But in addition to that, is it the case that his first request should be in a HtKeepAliveResponse
to tell the server to keep connection alive (it's not the Wire
that is supposed to do that), and the last request should be a HtAutoClosedResponse
to close the Wire
? So something like this?
try (final Wire wire = new HtKeepAliveWire("host")) {
final Text resp1 = new TextOf(
new HtKeepAliveResponse( // Tell the server to keep connection alive.
wire, "request1"
)
);
final Text resp2 = new TextOf(
new HtAutoClosedResponse( // Close the connection when byte stream ends.
wire, "request2"
)
);
}
Also, since only the server can specify the timeout
and rmax
parameters, and HtKeepAliveWire
is created by the user directly (not by the HtResponse
) to be reused by the subsequent requests, the @todo
description for this task is outdated? Specifically, HtKeepAliveWire
should not take these parameters in constructor?
from cactoos-http.
@llorllale ping
from cactoos-http.
@llorllale ping pong
from cactoos-http.
@vzurauskas sorry for the delay
Let's recap:
The Keep-Alive
header is a hint that can be sent by either the client or the server.
HtKeepAliveResponse
automatically injects the header into the user's HTTP request (decorates the request). We could perhaps rename it to avoid confusion.
HtKeepAliveWire
is unnecessary - it's just a dumb pipe that either endpoint may decide to close off at any time.
HtAutoClosedResponse
automatically closes the connection. Useful for one-offs, eg.:
// I don't want to reuse the wire
final String resp = new TextOf(
new HtAutoClosedResponse(
new HtResponse("http://servers-r-us.com")
)
).asString();
If you'd like multiple exchanges with the server on the same connection, you do:
try (final Wire wire = new HtWire("host")) {
final String resp1 = new TextOf(
new HtResponse(
wire,
"request1"
)
).asString();
final String resp2 = new TextOf(
new HtResponse(
wire,
"request2"
)
).asString();
}
from cactoos-http.
@vzurauskas there is one thing I think that's missing from the above - the snippet assumes the server responded with Keep-Alive
when in fact it may not. The example above would fail after the first request if the server decided to close the connection at the end of that exchange. You can inspect the headers of HtResponse
with HtHeaders
.
from cactoos-http.
@vzurauskas finally:
the
@todo
description for this task is outdated?
Yes. We don't need HtKeepAliveWire
at all.
from cactoos-http.
@llorllale Sorry for the delay, this time from me. :)
So if the client wanted to send two requests reusing the connection, the first request should include the Connection: Keep-Alive
header, right? Therefore the code would look like this (N.B. the first request/response is HtKeepAliveResponse
with timeout and rmax parameters) ?
try (final Wire wire = new HtWire("host")) {
final String resp1 = new TextOf(
new HtKeepAliveResponse(
wire,
5, // timeout
2, // rmax
"request1"
)
).asString();
final String resp2 = new TextOf(
new HtResponse(
wire,
"request2"
)
).asString();
}
If that's correct, and since this task already took a lot of time and the original description is very outdated now, perhaps I should rewrite the todo
according to our current understanding of what needs to be done, and we could close this task?
from cactoos-http.
@llorllale ping :)
from cactoos-http.
The job #74 assigned to @iakunin/z, here is why; the budget is 30 minutes, see §4; please, read §8 and §9; if the task is not clear, read this and this; there will be no monetary reward for this job
from cactoos-http.
@paulodamaso, this is a pretty obscure task. Could you get me the right direction here?
from cactoos-http.
@iakunin This issue is focused in implementing keep-alive connections by cactoos-http
client. Keep-alive connectios trade the keep-alive
header, so the server and the client would know the type of the http connection being used. Take a look at #74 (comment), it explains what shoud be implemented.
from cactoos-http.
from cactoos-http.
@iakunin The impediment for #74 was registered successfully by @iakunin/z
from cactoos-http.
The puzzle 20-eb4af059
has disappeared from the source code, that's why I closed this issue.
from cactoos-http.
The job #74 is now out of scope
from cactoos-http.
Order was finished: +30 point(s) just awarded to @iakunin/z
from cactoos-http.
Related Issues (20)
- GET Request example not work in Kotlin
- Dependency Dashboard
- EO violation in Wire? HOT 4
- Update jcabi-parent to 0.49.4 (solves xcop issue) HOT 4
- Update cactoos to 0.39 HOT 11
- BoundedByteBuffer.java:79-81: Figure out a more elegant... HOT 11
- HtWireTest.java:103-106: HtWire should not close the... HOT 17
- HtAutoClosedResponseTest.java:40-45: Introduce... HOT 14
- HtResponse.java:37-40: We need decorators for HtResponse... HOT 10
- Update maven-compiler-plugin and fix bug on it to allow incremental compilation HOT 2
- 'Get' class is in wrong package HOT 16
- Target architecture and main responsibilities HOT 2
- HtTimedWireTest.java:79-81: With #78 solved, HtWire... HOT 22
- Travis build fails installing oraclejdk8 HOT 9
- Upgrade openjdk HOT 13
- Bump copyright dates to 2020 HOT 10
- Change project ARC HOT 4
- BlockingSocketServer.java:45-52: Rework the... HOT 14
- BlockingSocketServer.java:98-100: Update cactoos to at... HOT 25
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 cactoos-http.