Skip to content

Commit

Permalink
More docs on timeout methods
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed May 10, 2024
1 parent c627084 commit c980055
Showing 1 changed file with 37 additions and 7 deletions.
44 changes: 37 additions & 7 deletions src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ final class Request extends HttpRequest

private float $inactivityTimeout = 10;

/** @var non-negative-int */
private int $bodySizeLimit = self::DEFAULT_BODY_SIZE_LIMIT;

/** @var non-negative-int */
private int $headerSizeLimit = self::DEFAULT_HEADER_SIZE_LIMIT;

/** @var null|\Closure(Request, Future): void */
Expand Down Expand Up @@ -344,9 +346,12 @@ public function getTcpConnectTimeout(): float
return $this->tcpConnectTimeout;
}

/**
* Set the timeout in seconds for establishing the TCP connection. Use 0 for no timeout.
*/
public function setTcpConnectTimeout(float $tcpConnectTimeout): void
{
$this->tcpConnectTimeout = $tcpConnectTimeout;
$this->tcpConnectTimeout = \max(0, $tcpConnectTimeout);
}

/**
Expand All @@ -357,22 +362,29 @@ public function getTlsHandshakeTimeout(): float
return $this->tlsHandshakeTimeout;
}

/**
* Set the timeout in seconds for the TLS handshake. Use 0 for no timeout.
*/
public function setTlsHandshakeTimeout(float $tlsHandshakeTimeout): void
{
$this->tlsHandshakeTimeout = $tlsHandshakeTimeout;
$this->tlsHandshakeTimeout = \max(0, $tlsHandshakeTimeout);
}

/**
* @return float Timeout in seconds for the HTTP transfer (not counting TCP connect and TLS handshake)
* @return float Timeout in seconds for the HTTP transfer (not counting TCP connect and TLS handshake).
*/
public function getTransferTimeout(): float
{
return $this->transferTimeout;
}

/**
* @param float $transferTimeout The timeout in seconds for the entire HTTP request transfer. Use 0 for no
* transfer timeout.
*/
public function setTransferTimeout(float $transferTimeout): void
{
$this->transferTimeout = $transferTimeout;
$this->transferTimeout = \max(0, $transferTimeout);
}

/**
Expand All @@ -383,29 +395,47 @@ public function getInactivityTimeout(): float
return $this->inactivityTimeout;
}

/**
* @param float $inactivityTimeout The timeout in seconds since the last data was received before the request
* fails due to inactivity. Use 0 for no inactivity timeout.
*/
public function setInactivityTimeout(float $inactivityTimeout): void
{
$this->inactivityTimeout = $inactivityTimeout;
$this->inactivityTimeout = \max(0, $inactivityTimeout);
}

/**
* @return non-negative-int Size limit of the response headers. Applies only to HTTP/1.x requests.
* 0 indicates no limit.
*/
public function getHeaderSizeLimit(): int
{
return $this->headerSizeLimit;
}

/**
* @param int $headerSizeLimit The size limit of response headers. Applies only to HTTP/1.x requests.
* Use 0 for no limit. Default is 16 KiB.
*/
public function setHeaderSizeLimit(int $headerSizeLimit): void
{
$this->headerSizeLimit = $headerSizeLimit;
$this->headerSizeLimit = \max(0, $headerSizeLimit);
}

/**
* @return int Size limit of the response body. 0 indicates no limit.
*/
public function getBodySizeLimit(): int
{
return $this->bodySizeLimit;
}

/**
* @param int $bodySizeLimit The size limit of the response body. Use 0 for no limit. Default is 10 MiB.
*/
public function setBodySizeLimit(int $bodySizeLimit): void
{
$this->bodySizeLimit = $bodySizeLimit;
$this->bodySizeLimit = \max(0, $bodySizeLimit);
}

/**
Expand Down

0 comments on commit c980055

Please sign in to comment.