Skip to content

Delay Request Connection #118

Closed
Closed
@cebe

Description

@cebe

I am working on a project which will make a lot of connections to external APIs and I need to queue the requests so that I can limit the number of active requests. This is needed to manage the load on the API (also may be useful for APIs that enforce a request limit).

For this reason I want to build the request and attach all event handlers, also write some data, but not yet send it.

Currently write() will directly open the connection and send the data.

http-client/src/Request.php

Lines 103 to 107 in d779a3b

// otherwise buffer and try to establish connection
$this->pendingWrites .= $data;
if (self::STATE_WRITING_HEAD > $this->state) {
$this->writeHead();
}

I suggest to add a method that allows adding data to $pendingWrites without sending the request.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions