PHPackages                             rancoud/http - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. rancoud/http

ActiveLibrary[Testing &amp; Quality](/categories/testing)

rancoud/http
============

Http package

5.0.1(2mo ago)219.4k↓11.1%21MITPHPPHP &gt;=8.4.0CI passing

Since Apr 29Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/rancoud/Http)[ Packagist](https://packagist.org/packages/rancoud/http)[ RSS](/packages/rancoud-http/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (32)Used By (1)

Http Package
============

[](#http-package)

[![Packagist PHP Version Support](https://camo.githubusercontent.com/03afbda79f6fbf26ac57ce5cb635fb524db88f59df60bff7fa5f57a91ed31216/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f72616e636f75642f68747470)](https://camo.githubusercontent.com/03afbda79f6fbf26ac57ce5cb635fb524db88f59df60bff7fa5f57a91ed31216/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f72616e636f75642f68747470)[![Packagist Version](https://camo.githubusercontent.com/e3e0cad839a6b3315b5915329ab80cdf48d3a85bd74fc054ddeebb0a92a66831/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72616e636f75642f68747470)](https://packagist.org/packages/rancoud/http)[![Packagist Downloads](https://camo.githubusercontent.com/bae9efcaaa066306a40336f72b79c6773cc339108ba10df514a72410b5cd4ed6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f72616e636f75642f68747470)](https://packagist.org/packages/rancoud/http)[![Composer dependencies](https://camo.githubusercontent.com/aae95fbaa83bc6a3f4597f3a75da45ea46ec236fc324617f0e5a2f15e07fe750/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646570656e64656e636965732d302d627269676874677265656e)](https://github.com/rancoud/http/blob/master/composer.json)[![Test workflow](https://camo.githubusercontent.com/91c77c7ed1743b2a12ba128af2c16af51956990cba951550d8401e1204648443/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f72616e636f75642f687474702f746573742e796d6c3f6272616e63683d6d6173746572)](https://github.com/rancoud/http/actions/workflows/test.yml)[![Codecov](https://camo.githubusercontent.com/857d32ab63d6700d95c9f48afc2864c7ae4003b0aaadf7c7663277143bb9c39f/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f72616e636f75642f687474703f6c6f676f3d636f6465636f76)](https://codecov.io/gh/rancoud/http)

Heavily based on [Nyholm](https://github.com/nyholm) works from the psr7 repository

Http with PSR 7 15 17 18.

Installation
------------

[](#installation)

```
composer require rancoud/http
```

How to use it?
--------------

[](#how-to-use-it)

```
$factory = new Rancoud\Http\Message\Factory\Factory();
$request = $factory->createRequest('GET', 'https://example.com');
$stream = $factory->createStream('foobar');
```

Client
------

[](#client)

### Methods

[](#methods)

- sendRequest(request: RequestInterface): ResponseInterface
- setCAInfosPath(\[infos: string = null\], \[path: string = null\]): self
- disableSSLVerification(): self
- enableSSLVerification(): self

Factory
-------

[](#factory)

### Methods

[](#methods-1)

- createRequest(method: string, uri: mixed): RequestInterface
- createResponse(\[code: int = 200\], \[reasonPhrase: string = ''\]): ResponseInterface
- createResponseBody(\[code: int = 200\], \[body: mixed = null\]): ResponseInterface
- createRedirection(location: string): ResponseInterface
- createStream(\[content: string = ''\]): StreamInterface
- createStreamFromFile(filename: string, \[mode: string = 'r'\]): StreamInterface
- createStreamFromResource(resource: mixed): StreamInterface
- createUploadedFile(stream: StreamInterface, \[size: int = null\], \[error: int = \\UPLOAD\_ERR\_OK\], \[clientFilename: string = null\], \[clientMediaType: string = null\]): UploadedFileInterface
- createUri(\[uri: string = ''\]): UriInterface
- createUriFromArray(server: array): UriInterface
- createServerRequest(method: string, uri: mixed, \[serverParams: array = \[\]\]): ServerRequestInterface
- createServerRequestFromArray(server: array): ServerRequestInterface
- createServerRequestFromArrays(server: array, headers: array, cookie: array, get: array, post: array, files: array): ServerRequestInterface
- createServerRequestFromGlobals(): ServerRequestInterface

Request
-------

[](#request)

### Constructor

[](#constructor)

#### Mandatory

[](#mandatory)

ParameterTypeDescriptionmethodstringHTTP methodurimixedUri#### Optionnals

[](#optionnals)

ParameterTypeDefault valueDescriptionheadersarray\[\]Request headersbodymixed\[\]Request bodyversionstring'1.1'HTTP protocol version### Methods

[](#methods-2)

- getBody(): StreamInterface
- getHeader(name: string): array
- getHeaderLine(name: string): string
- getHeaders(): array
- getMethod(): string
- getProtocolVersion(): string
- getRequestTarget(): string
- getUri(): UriInterface
- hasHeader(name: string): bool
- removeHeader(name: string): self
- addHeader(name: string, value: mixed): self
- withBody(body: StreamInterface): self
- withHeader(name: string, value: mixed): self
- withMethod(method: string): self
- withProtocolVersion(version: string): self
- withRequestTarget(requestTarget: string): self
- withUri(uri: UriInterface, \[preserveHost: bool = false\]): self

### HTTP Methods supported

[](#http-methods-supported)

- ACL
- BASELINE-CONTROL
- BCOPY
- BDELETE
- BIND
- BMOVE
- BPROPFIND
- BPROPPATCH
- CHECKIN
- CHECKOUT
- CONNECT
- COPY
- DELETE
- GET
- HEAD
- LABEL
- LINK
- LOCK
- M-SEARCH
- MERGE
- MKACTIVITY
- MKCALENDAR
- MKCOL
- MKREDIRECTREF
- MKWORKSPACE
- MOVE
- NOTIFY
- OPTIONS
- ORDERPATCH
- PATCH
- POLL
- POST
- PRI
- PROPFIND
- PROPPATCH
- PURGE
- PUT
- REBIND
- REPORT
- SEARCH
- SUBSCRIBE
- TRACE
- UNBIND
- UNCHECKOUT
- UNLINK
- UNLOCK
- UNSUBSCRIBE
- UPDATE
- UPDATEREDIRECTREF
- VERSION-CONTROL
- VIEW
- X-MS-ENUMATTS

Response
--------

[](#response)

### Constructor

[](#constructor-1)

#### Optionnals

[](#optionnals-1)

ParameterTypeDefault valueDescriptionstatusint200Status codeheadersarray\[\]Response headersbodymixed\[\]Response bodyversionstring'1.1'HTTP protocol versionreasonstringnullString send after status code### Methods

[](#methods-3)

- getBody(): StreamInterface
- getHeader(name: string): array
- getHeaderLine(name: string): string
- getHeaders(): array
- getProtocolVersion(): string
- getReasonPhrase(): string
- getStatusCode(): int
- hasHeader(name: string): bool
- send(\[bodyChunkSize: int = 8192\]): void
- withAddedHeader(name: string, value: mixed): self
- withBody(body: StreamInterface): self
- withHeader(name: string, value: mixed): self
- withoutHeader(name: string): self
- withProtocolVersion(version: string): self
- withStatus(code: int, \[reasonPhrase: string = ''\]): self

### Status Code and Reasons Phrases supported

[](#status-code-and-reasons-phrases-supported)

- 100 =&gt; Continue
- 101 =&gt; Switching Protocols
- 102 =&gt; Processing
- 103 =&gt; Early Hints
- 200 =&gt; OK
- 201 =&gt; Created
- 202 =&gt; Accepted
- 203 =&gt; Non-Authoritative Information
- 204 =&gt; No Content
- 205 =&gt; Reset Content
- 206 =&gt; Partial Content
- 207 =&gt; Multi-status
- 208 =&gt; Already Reported
- 210 =&gt; Content Different
- 226 =&gt; IM Used
- 300 =&gt; Multiple Choices
- 301 =&gt; Moved Permanently
- 302 =&gt; Found
- 303 =&gt; See Other
- 304 =&gt; Not Modified
- 305 =&gt; Use Proxy
- 306 =&gt; Switch Proxy
- 307 =&gt; Temporary Redirect
- 308 =&gt; Permanent Redirect
- 310 =&gt; Too many Redirects
- 400 =&gt; Bad Request
- 401 =&gt; Unauthorized
- 402 =&gt; Payment Required
- 403 =&gt; Forbidden
- 404 =&gt; Not Found
- 405 =&gt; Method Not Allowed
- 406 =&gt; Not Acceptable
- 407 =&gt; Proxy Authentication Required
- 408 =&gt; Request Timeout
- 409 =&gt; Conflict
- 410 =&gt; Gone
- 411 =&gt; Length Required
- 412 =&gt; Precondition Failed
- 413 =&gt; Payload Too Large
- 414 =&gt; URI Too Long
- 415 =&gt; Unsupported Media Type
- 416 =&gt; Range Not Satisfiable
- 417 =&gt; Expectation Failed
- 418 =&gt; I'm a teapot
- 421 =&gt; Misdirected Request
- 422 =&gt; Unprocessable Entity
- 423 =&gt; Locked
- 424 =&gt; Failed Dependency
- 425 =&gt; Unordered Collection
- 426 =&gt; Upgrade Required
- 428 =&gt; Precondition Required
- 429 =&gt; Too Many Requests
- 431 =&gt; Request Header Fields Too Large
- 444 =&gt; No Response
- 449 =&gt; Retry With
- 450 =&gt; Blocked by Windows Parental Controls
- 451 =&gt; Unavailable For Legal Reasons
- 456 =&gt; Unrecoverable Error
- 495 =&gt; SSL Certificate Error
- 496 =&gt; SSL Certificate Required
- 497 =&gt; HTTP Request Sent to HTTPS Port
- 499 =&gt; Client has closed connection
- 500 =&gt; Internal Server Error
- 501 =&gt; Not Implemented
- 502 =&gt; Bad Gateway
- 503 =&gt; Service Unavailable
- 504 =&gt; Gateway Timeout
- 505 =&gt; HTTP Version Not Supported
- 506 =&gt; Variant Also Negotiates
- 507 =&gt; Insufficient Storage
- 508 =&gt; Loop Detected
- 509 =&gt; Bandwidth Limit Exceeded
- 510 =&gt; Not extended
- 511 =&gt; Network Authentication Required
- 520 =&gt; Unknown Error
- 521 =&gt; Web Server Is Down
- 522 =&gt; Connection Timed Out
- 523 =&gt; Origin Is Unreachable
- 524 =&gt; A Timeout Occurred
- 525 =&gt; SSL Handshake Failed
- 526 =&gt; Invalid SSL Certificate
- 527 =&gt; Railgun Error
- 599 =&gt; Network Connect Timeout Error
- 701 =&gt; Meh
- 702 =&gt; Emacs
- 703 =&gt; Explosion
- 704 =&gt; Goto Fail
- 705 =&gt; I wrote the code and missed the necessary validation by an oversight (see 795)
- 706 =&gt; Delete Your Account
- 707 =&gt; Can't quit vi
- 710 =&gt; PHP
- 711 =&gt; Convenience Store
- 712 =&gt; NoSQL
- 718 =&gt; I am not a teapot
- 719 =&gt; Haskell
- 720 =&gt; Unpossible
- 721 =&gt; Known Unknowns
- 722 =&gt; Unknown Unknowns
- 723 =&gt; Tricky
- 724 =&gt; This line should be unreachable
- 725 =&gt; It works on my machine
- 726 =&gt; It's a feature, not a bug
- 727 =&gt; 32 bits is plenty
- 728 =&gt; It works in my timezone
- 730 =&gt; Fucking npm
- 731 =&gt; Fucking Rubygems
- 732 =&gt; Fucking Unic💩de
- 733 =&gt; Fucking Deadlocks
- 734 =&gt; Fucking Deferreds
- 735 =&gt; Fucking IE
- 736 =&gt; Fucking Race Conditions
- 737 =&gt; FuckThreadsing
- 739 =&gt; Fucking Windows
- 740 =&gt; Got the brains trust on the case.
- 750 =&gt; Didn't bother to compile it
- 753 =&gt; Syntax Error
- 754 =&gt; Too many semi-colons
- 755 =&gt; Not enough semi-colons
- 756 =&gt; Insufficiently polite
- 757 =&gt; Excessively polite
- 759 =&gt; Unexpected "T\_PAAMAYIM\_NEKUDOTAYIM"
- 761 =&gt; Hungover
- 762 =&gt; Stoned
- 763 =&gt; Under-Caffeinated
- 764 =&gt; Over-Caffeinated
- 765 =&gt; Railscamp
- 766 =&gt; Sober
- 767 =&gt; Drunk
- 768 =&gt; Accidentally Took Sleeping Pills Instead Of Migraine Pills During Crunch Week
- 771 =&gt; Cached for too long
- 772 =&gt; Not cached long enough
- 773 =&gt; Not cached at all
- 774 =&gt; Why was this cached?
- 775 =&gt; Out of cash
- 776 =&gt; Error on the Exception
- 777 =&gt; Coincidence
- 778 =&gt; Off By One Error
- 779 =&gt; Off By Too Many To Count Error
- 780 =&gt; Project owner not responding
- 781 =&gt; Operations
- 782 =&gt; QA
- 783 =&gt; It was a customer request, honestly
- 784 =&gt; Management, obviously
- 785 =&gt; TPS Cover Sheet not attached
- 786 =&gt; Try it now
- 787 =&gt; Further Funding Required
- 788 =&gt; Designer's final designs weren't
- 789 =&gt; Not my department
- 791 =&gt; The Internet shut down due to copyright restrictions
- 792 =&gt; Climate change driven catastrophic weather event
- 793 =&gt; Zombie Apocalypse
- 794 =&gt; Someone let PG near a REPL
- 795 =&gt; #heartbleed (see 705)
- 796 =&gt; Some DNS fuckery idno
- 797 =&gt; This is the last page of the Internet. Go back
- 798 =&gt; I checked the db backups cupboard and the cupboard was bare
- 799 =&gt; End of the world

ServerRequest
-------------

[](#serverrequest)

### Constructor

[](#constructor-2)

#### Mandatory

[](#mandatory-1)

ParameterTypeDescriptionmethodstringHTTP methodurimixedUri#### Optionnals

[](#optionnals-2)

ParameterTypeDefault valueDescriptionheadersarray\[\]Request headersbodymixed\[\]Request bodyversionstring'1.1'HTTP protocol versionserverParamsarray\[\]Server parameters### Methods

[](#methods-4)

- getAttribute(name: string, \[default: mixed = null\]): mixed|null
- getAttributes(): array
- getBody(): StreamInterface
- getCookieParams(): array
- getHeader(name: string): array
- getHeaderLine(name: string): string
- getHeaders(): array
- getMethod(): string
- getParsedBody(): array|null|object
- getProtocolVersion(): string
- getQueryParams(): array
- getRequestTarget(): string
- getServerParams(): array
- getUploadedFiles(): array
- getUri(): UriInterface
- hasHeader(name: string): bool
- withAddedHeader(name: string, value: mixed): self
- withAttribute(name: string, value: mixed): self
- withBody(body: StreamInterface): self
- withCookieParams(cookies: array): self
- withHeader(name: string, value: mixed): self
- withMethod(method: string): self
- withoutAttribute(name: string): self
- withoutHeader(name: string): self
- withParsedBody(data: array|null|object): self
- withProtocolVersion(version: string): self
- withQueryParams(query: array): self
- withRequestTarget(requestTarget: string): self
- withUploadedFiles(uploadedFiles: array): self
- withUri(uri: UriInterface, \[preserveHost: bool = false\]): self

Stream
------

[](#stream)

### Methods

[](#methods-5)

- \_\_destruct(): void
- \_\_toString(): string
- close(): void
- detach(): null|resource
- eof(): bool
- getContents(): string
- getMetadata(\[key: string|null = null\]): ?array
- getSize(): ?int
- isReadable(): bool
- isSeekable(): bool
- isWritable(): bool
- read(length: int): string
- rewind(): void
- seek(offset: int, \[whence: int = \\SEEK\_SET\]): void
- tell(): int
- write(string: string): bool|int

### Static Methods

[](#static-methods)

- create(\[content: string = ''\]): StreamInterface

UploadedFile
------------

[](#uploadedfile)

### Constructor

[](#constructor-3)

#### Mandatory

[](#mandatory-2)

ParameterTypeDescriptionstreamOrFilemixedStream or filesizeintFilesizeerrorStatusintUpload errors#### Optionnals

[](#optionnals-3)

ParameterTypeDefault valueDescriptionclientFilenamestring|nullnullFilenameclientMediaTypestring|nullnullMedia type### Methods

[](#methods-6)

- getClientFilename(): ?string
- getClientMediaType(): ?string
- getError(): int
- getSize(): ?int
- getStream(): StreamInterface
- getFilename(): ?string
- moveTo(targetPath: string): void

### Upload errors supported

[](#upload-errors-supported)

- UPLOAD\_ERR\_OK
- UPLOAD\_ERR\_INI\_SIZE
- UPLOAD\_ERR\_FORM\_SIZE
- UPLOAD\_ERR\_PARTIAL
- UPLOAD\_ERR\_NO\_FILE
- UPLOAD\_ERR\_NO\_TMP\_DIR
- UPLOAD\_ERR\_CANT\_WRITE
- UPLOAD\_ERR\_EXTENSION

Uri
---

[](#uri)

### Constructor

[](#constructor-4)

#### Optionnals

[](#optionnals-4)

ParameterTypeDefault valueDescriptionuristring''Uri### Methods

[](#methods-7)

- \_\_toString(): string
- getAuthority(): string
- getFragment(): string
- getHost(): string
- getPath(): string
- getPort(): ?int
- getQuery(): string
- getScheme(): string
- getUserInfo(): string
- withFragment(fragment: string): self
- withHost(host: string): self
- withPath(path: string): self
- withPort(port: int|null): self
- withQuery(query: string): self
- withScheme(scheme: string): self
- withUserInfo(user: string, \[password: string|null = null\]): self

How to Dev
----------

[](#how-to-dev)

`composer ci` for php-cs-fixer and phpunit and coverage
`composer lint` for php-cs-fixer
`composer test` for phpunit and coverage

###  Health Score

61

—

FairBetter than 99% of packages

Maintenance89

Actively maintained with recent releases

Popularity30

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity92

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 72.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~99 days

Recently: every ~116 days

Total

30

Last Release

64d ago

Major Versions

1.1.1 → 2.0.02020-07-09

2.0.0 → 3.0.02020-07-17

3.3.0 → 4.0.02024-12-07

4.0.1 → 5.0.02025-04-20

PHP version history (3 changes)1.0.0PHP &gt;=7.2.0

2.0.0PHP &gt;=7.4.0

5.0.0PHP &gt;=8.4.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/829a536bd4f71cadcd0266e272ccaf413e3fc9f2937248c9a2317ef0bf2d25ee?d=identicon)[rancoud](/maintainers/rancoud)

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (264 commits)")[![rancoud](https://avatars.githubusercontent.com/u/1884186?v=4)](https://github.com/rancoud "rancoud (101 commits)")[![Godnite](https://avatars.githubusercontent.com/u/10619405?v=4)](https://github.com/Godnite "Godnite (1 commits)")

---

Tags

composercoveragehttppackagistphpphp7php8phpunitpsrpsr-15psr-17psr-18psr-7

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/rancoud-http/health.svg)

```
[![Health](https://phpackages.com/badges/rancoud-http/health.svg)](https://phpackages.com/packages/rancoud-http)
```

###  Alternatives

[phpspec/prophecy

Highly opinionated mocking framework for PHP 5.3+

8.5k551.7M682](/packages/phpspec-prophecy)[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)[beberlei/assert

Thin assertion library for input validation in business models.

2.4k96.9M570](/packages/beberlei-assert)[mikey179/vfsstream

Virtual file system to mock the real file system in unit tests.

1.4k108.0M2.7k](/packages/mikey179-vfsstream)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)[phpspec/phpspec

Specification-oriented BDD framework for PHP 7.1+

1.9k36.7M3.1k](/packages/phpspec-phpspec)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
