Giter Site home page Giter Site logo

Comments (25)

0crat avatar 0crat commented on July 16, 2024

@llorllale/z please, pay attention to this issue

from cactoos-http.

0crat avatar 0crat commented on July 16, 2024

Job #74 is now in scope, role is DEV

from cactoos-http.

0crat avatar 0crat commented on July 16, 2024

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.

Umbrah avatar Umbrah commented on July 16, 2024

@0crat refuse

from cactoos-http.

0crat avatar 0crat commented on July 16, 2024

@0crat refuse (here)

@Umbrah The user @Umbrah/z resigned from #74, please stop working. Reason for job resignation: Order was cancelled

from cactoos-http.

0crat avatar 0crat commented on July 16, 2024

Tasks refusal is discouraged, see §6: -15 point(s) just awarded to @Umbrah/z

from cactoos-http.

0crat avatar 0crat commented on July 16, 2024

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.

vzurauskas avatar vzurauskas commented on July 16, 2024

@0crat wait for #84

from cactoos-http.

0crat avatar 0crat commented on July 16, 2024

@0crat wait for #84 (here)

@vzurauskas The impediment for #74 was registered successfully by @vzurauskas/z

from cactoos-http.

vzurauskas avatar vzurauskas commented on July 16, 2024

@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.

vzurauskas avatar vzurauskas commented on July 16, 2024

@llorllale ping

from cactoos-http.

vzurauskas avatar vzurauskas commented on July 16, 2024

@llorllale ping pong

from cactoos-http.

llorllale avatar llorllale commented on July 16, 2024

@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.

llorllale avatar llorllale commented on July 16, 2024

@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.

llorllale avatar llorllale commented on July 16, 2024

@vzurauskas finally:

the @todo description for this task is outdated?

Yes. We don't need HtKeepAliveWire at all.

from cactoos-http.

vzurauskas avatar vzurauskas commented on July 16, 2024

@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.

vzurauskas avatar vzurauskas commented on July 16, 2024

@llorllale ping :)

from cactoos-http.

0crat avatar 0crat commented on July 16, 2024

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.

iakunin avatar iakunin commented on July 16, 2024

@paulodamaso, this is a pretty obscure task. Could you get me the right direction here?

from cactoos-http.

paulodamaso avatar paulodamaso commented on July 16, 2024

@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.

iakunin avatar iakunin commented on July 16, 2024

@0crat waiting for review #95

from cactoos-http.

0crat avatar 0crat commented on July 16, 2024

@0crat waiting for review #95 (here)

@iakunin The impediment for #74 was registered successfully by @iakunin/z

from cactoos-http.

0pdd avatar 0pdd commented on July 16, 2024

The puzzle 20-eb4af059 has disappeared from the source code, that's why I closed this issue.

from cactoos-http.

0crat avatar 0crat commented on July 16, 2024

The job #74 is now out of scope

from cactoos-http.

0crat avatar 0crat commented on July 16, 2024

Order was finished: +30 point(s) just awarded to @iakunin/z

from cactoos-http.

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.