{"id":15029730,"url":"https://github.com/rancoud/http","last_synced_at":"2025-04-09T20:32:43.176Z","repository":{"id":37579849,"uuid":"130604177","full_name":"rancoud/Http","owner":"rancoud","description":"Http package","archived":false,"fork":false,"pushed_at":"2025-04-01T12:20:30.000Z","size":3114,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-01T13:27:55.684Z","etag":null,"topics":["composer","coverage","http","packagist","php","php74","php8","php80","php81","phpunit","phpunit9","psr","psr-15","psr-17","psr-18","psr-7"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/rancoud/http","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rancoud.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-04-22T20:18:51.000Z","updated_at":"2025-04-01T12:20:33.000Z","dependencies_parsed_at":"2024-02-03T17:39:42.995Z","dependency_job_id":"4827dfa4-02a3-4ee2-84c5-a6f0a84a31a5","html_url":"https://github.com/rancoud/Http","commit_stats":{"total_commits":167,"total_committers":4,"mean_commits":41.75,"dds":0.4610778443113772,"last_synced_commit":"5c2ee13002f0e52874e5153d7c642f3cdc1f9866"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rancoud%2FHttp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rancoud%2FHttp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rancoud%2FHttp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rancoud%2FHttp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rancoud","download_url":"https://codeload.github.com/rancoud/Http/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248107674,"owners_count":21048977,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["composer","coverage","http","packagist","php","php74","php8","php80","php81","phpunit","phpunit9","psr","psr-15","psr-17","psr-18","psr-7"],"created_at":"2024-09-24T20:11:30.553Z","updated_at":"2025-04-09T20:32:43.139Z","avatar_url":"https://github.com/rancoud.png","language":"PHP","readme":"# Http Package\n\n![Packagist PHP Version Support](https://img.shields.io/packagist/php-v/rancoud/http)\n[![Packagist Version](https://img.shields.io/packagist/v/rancoud/http)](https://packagist.org/packages/rancoud/http)\n[![Packagist Downloads](https://img.shields.io/packagist/dt/rancoud/http)](https://packagist.org/packages/rancoud/http)\n[![Composer dependencies](https://img.shields.io/badge/dependencies-0-brightgreen)](https://github.com/rancoud/http/blob/master/composer.json)\n[![Test workflow](https://img.shields.io/github/actions/workflow/status/rancoud/http/test.yml?branch=master)](https://github.com/rancoud/http/actions/workflows/test.yml)\n[![Codecov](https://img.shields.io/codecov/c/github/rancoud/http?logo=codecov)](https://codecov.io/gh/rancoud/http)\n\nHeavily based on [Nyholm](https://github.com/nyholm) works from the psr7 repository [https://github.com/nyholm/psr7](https://github.com/nyholm/psr7)\n\nHttp with PSR 7 15 17 18.\n\n## Installation\n```php\ncomposer require rancoud/http\n```\n\n## How to use it?\n```php\n$factory = new Rancoud\\Http\\Message\\Factory\\Factory();\n$request = $factory-\u003ecreateRequest('GET', 'https://example.com');\n$stream = $factory-\u003ecreateStream('foobar');\n```\n\n## Client\n### Methods\n* sendRequest(request: RequestInterface): ResponseInterface\n* setCAInfosPath([infos: string = null], [path: string = null]): self\n* disableSSLVerification(): self\n* enableSSLVerification(): self\n\n## Factory\n### Methods\n* createRequest(method: string, uri: mixed): RequestInterface\n* createResponse([code: int = 200], [reasonPhrase: string = '']): ResponseInterface\n* createResponseBody([code: int = 200], [body: mixed = null]): ResponseInterface\n* createRedirection(location: string): ResponseInterface\n* createStream([content: string = '']): StreamInterface\n* createStreamFromFile(filename: string, [mode: string = 'r']): StreamInterface\n* createStreamFromResource(resource: mixed): StreamInterface\n* createUploadedFile(stream: StreamInterface, [size: int = null], [error: int = \\UPLOAD_ERR_OK], [clientFilename: string = null], [clientMediaType: string = null]): UploadedFileInterface\n* createUri([uri: string = '']): UriInterface\n* createUriFromArray(server: array): UriInterface\n* createServerRequest(method: string, uri: mixed, [serverParams: array = []]): ServerRequestInterface\n* createServerRequestFromArray(server: array): ServerRequestInterface\n* createServerRequestFromArrays(server: array, headers: array, cookie: array, get: array, post: array, files: array): ServerRequestInterface\n* createServerRequestFromGlobals(): ServerRequestInterface\n\n## Request\n### Constructor\n#### Mandatory\n| Parameter | Type   | Description |\n|-----------|--------|-------------|\n| method    | string | HTTP method |\n| uri       | mixed  | Uri         |\n\n#### Optionnals\n| Parameter | Type   | Default value | Description           |\n|-----------|--------|---------------|-----------------------|\n| headers   | array  | []            | Request headers       |\n| body      | mixed  | []            | Request body          |\n| version   | string | '1.1'         | HTTP protocol version |\n\n### Methods\n* getBody(): StreamInterface\n* getHeader(name: string): array\n* getHeaderLine(name: string): string\n* getHeaders(): array\n* getMethod(): string\n* getProtocolVersion(): string\n* getRequestTarget(): string\n* getUri(): UriInterface\n* hasHeader(name: string): bool\n* removeHeader(name: string): self\n* addHeader(name: string, value: mixed): self\n* withBody(body: StreamInterface): self\n* withHeader(name: string, value: mixed): self\n* withMethod(method: string): self\n* withProtocolVersion(version: string): self\n* withRequestTarget(requestTarget: string): self\n* withUri(uri: UriInterface, [preserveHost: bool = false]): self\n\n### HTTP Methods supported\n* ACL\n* BASELINE-CONTROL\n* BCOPY\n* BDELETE\n* BIND\n* BMOVE\n* BPROPFIND\n* BPROPPATCH\n* CHECKIN\n* CHECKOUT\n* CONNECT\n* COPY\n* DELETE\n* GET\n* HEAD\n* LABEL\n* LINK\n* LOCK\n* M-SEARCH\n* MERGE\n* MKACTIVITY\n* MKCALENDAR\n* MKCOL\n* MKREDIRECTREF\n* MKWORKSPACE\n* MOVE\n* NOTIFY\n* OPTIONS\n* ORDERPATCH\n* PATCH\n* POLL\n* POST\n* PRI\n* PROPFIND\n* PROPPATCH\n* PURGE\n* PUT\n* REBIND\n* REPORT\n* SEARCH\n* SUBSCRIBE\n* TRACE\n* UNBIND\n* UNCHECKOUT\n* UNLINK\n* UNLOCK\n* UNSUBSCRIBE\n* UPDATE\n* UPDATEREDIRECTREF\n* VERSION-CONTROL\n* VIEW\n* X-MS-ENUMATTS\n\n## Response\n### Constructor\n#### Optionnals\n| Parameter | Type   | Default value | Description                   |\n|-----------|--------|---------------|-------------------------------|\n| status    | int    | 200           | Status code                   |\n| headers   | array  | []            | Response headers              |\n| body      | mixed  | []            | Response body                 |\n| version   | string | '1.1'         | HTTP protocol version         |\n| reason    | string | null          | String send after status code |\n\n### Methods\n* getBody(): StreamInterface\n* getHeader(name: string): array\n* getHeaderLine(name: string): string\n* getHeaders(): array\n* getProtocolVersion(): string\n* getReasonPhrase(): string\n* getStatusCode(): int\n* hasHeader(name: string): bool\n* send([bodyChunkSize: int = 8192]): void\n* withAddedHeader(name: string, value: mixed): self\n* withBody(body: StreamInterface): self\n* withHeader(name: string, value: mixed): self\n* withoutHeader(name: string): self\n* withProtocolVersion(version: string): self\n* withStatus(code: int, [reasonPhrase: string = '']): self\n\n### Status Code and Reasons Phrases supported\n* 100 =\u003e Continue\n* 101 =\u003e Switching Protocols\n* 102 =\u003e Processing\n* 103 =\u003e Early Hints\n* 200 =\u003e OK\n* 201 =\u003e Created\n* 202 =\u003e Accepted\n* 203 =\u003e Non-Authoritative Information\n* 204 =\u003e No Content\n* 205 =\u003e Reset Content\n* 206 =\u003e Partial Content\n* 207 =\u003e Multi-status\n* 208 =\u003e Already Reported\n* 210 =\u003e Content Different\n* 226 =\u003e IM Used\n* 300 =\u003e Multiple Choices\n* 301 =\u003e Moved Permanently\n* 302 =\u003e Found\n* 303 =\u003e See Other\n* 304 =\u003e Not Modified\n* 305 =\u003e Use Proxy\n* 306 =\u003e Switch Proxy\n* 307 =\u003e Temporary Redirect\n* 308 =\u003e Permanent Redirect\n* 310 =\u003e Too many Redirects\n* 400 =\u003e Bad Request\n* 401 =\u003e Unauthorized\n* 402 =\u003e Payment Required\n* 403 =\u003e Forbidden\n* 404 =\u003e Not Found\n* 405 =\u003e Method Not Allowed\n* 406 =\u003e Not Acceptable\n* 407 =\u003e Proxy Authentication Required\n* 408 =\u003e Request Timeout\n* 409 =\u003e Conflict\n* 410 =\u003e Gone\n* 411 =\u003e Length Required\n* 412 =\u003e Precondition Failed\n* 413 =\u003e Payload Too Large\n* 414 =\u003e URI Too Long\n* 415 =\u003e Unsupported Media Type\n* 416 =\u003e Range Not Satisfiable\n* 417 =\u003e Expectation Failed\n* 418 =\u003e I'm a teapot\n* 421 =\u003e Misdirected Request\n* 422 =\u003e Unprocessable Entity\n* 423 =\u003e Locked\n* 424 =\u003e Failed Dependency\n* 425 =\u003e Unordered Collection\n* 426 =\u003e Upgrade Required\n* 428 =\u003e Precondition Required\n* 429 =\u003e Too Many Requests\n* 431 =\u003e Request Header Fields Too Large\n* 444 =\u003e No Response\n* 449 =\u003e Retry With\n* 450 =\u003e Blocked by Windows Parental Controls\n* 451 =\u003e Unavailable For Legal Reasons\n* 456 =\u003e Unrecoverable Error\n* 495 =\u003e SSL Certificate Error\n* 496 =\u003e SSL Certificate Required\n* 497 =\u003e HTTP Request Sent to HTTPS Port\n* 499 =\u003e Client has closed connection\n* 500 =\u003e Internal Server Error\n* 501 =\u003e Not Implemented\n* 502 =\u003e Bad Gateway\n* 503 =\u003e Service Unavailable\n* 504 =\u003e Gateway Timeout\n* 505 =\u003e HTTP Version Not Supported\n* 506 =\u003e Variant Also Negotiates\n* 507 =\u003e Insufficient Storage\n* 508 =\u003e Loop Detected\n* 509 =\u003e Bandwidth Limit Exceeded\n* 510 =\u003e Not extended\n* 511 =\u003e Network Authentication Required\n* 520 =\u003e Unknown Error\n* 521 =\u003e Web Server Is Down\n* 522 =\u003e Connection Timed Out\n* 523 =\u003e Origin Is Unreachable\n* 524 =\u003e A Timeout Occurred\n* 525 =\u003e SSL Handshake Failed\n* 526 =\u003e Invalid SSL Certificate\n* 527 =\u003e Railgun Error\n* 599 =\u003e Network Connect Timeout Error\n* 701 =\u003e Meh\n* 702 =\u003e Emacs\n* 703 =\u003e Explosion\n* 704 =\u003e Goto Fail\n* 705 =\u003e I wrote the code and missed the necessary validation by an oversight (see 795)\n* 706 =\u003e Delete Your Account\n* 707 =\u003e Can't quit vi\n* 710 =\u003e PHP\n* 711 =\u003e Convenience Store\n* 712 =\u003e NoSQL\n* 718 =\u003e I am not a teapot\n* 719 =\u003e Haskell\n* 720 =\u003e Unpossible\n* 721 =\u003e Known Unknowns\n* 722 =\u003e Unknown Unknowns\n* 723 =\u003e Tricky\n* 724 =\u003e This line should be unreachable\n* 725 =\u003e It works on my machine\n* 726 =\u003e It's a feature, not a bug\n* 727 =\u003e 32 bits is plenty\n* 728 =\u003e It works in my timezone\n* 730 =\u003e Fucking npm\n* 731 =\u003e Fucking Rubygems\n* 732 =\u003e Fucking Unic\u0026#128169;de\n* 733 =\u003e Fucking Deadlocks\n* 734 =\u003e Fucking Deferreds\n* 735 =\u003e Fucking IE\n* 736 =\u003e Fucking Race Conditions\n* 737 =\u003e FuckThreadsing\n* 739 =\u003e Fucking Windows\n* 740 =\u003e Got the brains trust on the case.\n* 750 =\u003e Didn't bother to compile it\n* 753 =\u003e Syntax Error\n* 754 =\u003e Too many semi-colons\n* 755 =\u003e Not enough semi-colons\n* 756 =\u003e Insufficiently polite\n* 757 =\u003e Excessively polite\n* 759 =\u003e Unexpected \"T_PAAMAYIM_NEKUDOTAYIM\"\n* 761 =\u003e Hungover\n* 762 =\u003e Stoned\n* 763 =\u003e Under-Caffeinated\n* 764 =\u003e Over-Caffeinated\n* 765 =\u003e Railscamp\n* 766 =\u003e Sober\n* 767 =\u003e Drunk\n* 768 =\u003e Accidentally Took Sleeping Pills Instead Of Migraine Pills During Crunch Week\n* 771 =\u003e Cached for too long\n* 772 =\u003e Not cached long enough\n* 773 =\u003e Not cached at all\n* 774 =\u003e Why was this cached?\n* 775 =\u003e Out of cash\n* 776 =\u003e Error on the Exception\n* 777 =\u003e Coincidence\n* 778 =\u003e Off By One Error\n* 779 =\u003e Off By Too Many To Count Error\n* 780 =\u003e Project owner not responding\n* 781 =\u003e Operations\n* 782 =\u003e QA\n* 783 =\u003e It was a customer request, honestly\n* 784 =\u003e Management, obviously\n* 785 =\u003e TPS Cover Sheet not attached\n* 786 =\u003e Try it now\n* 787 =\u003e Further Funding Required\n* 788 =\u003e Designer's final designs weren't\n* 789 =\u003e Not my department\n* 791 =\u003e The Internet shut down due to copyright restrictions\n* 792 =\u003e Climate change driven catastrophic weather event\n* 793 =\u003e Zombie Apocalypse\n* 794 =\u003e Someone let PG near a REPL\n* 795 =\u003e #heartbleed (see 705)\n* 796 =\u003e Some DNS fuckery idno\n* 797 =\u003e This is the last page of the Internet.  Go back\n* 798 =\u003e I checked the db backups cupboard and the cupboard was bare\n* 799 =\u003e End of the world\n\n## ServerRequest\n### Constructor\n#### Mandatory\n| Parameter | Type   | Description |\n|-----------|--------|-------------|\n| method    | string | HTTP method |\n| uri       | mixed  | Uri         |\n\n#### Optionnals\n| Parameter    | Type   | Default value | Description           |\n|--------------|--------|---------------|-----------------------|\n| headers      | array  | []            | Request headers       |\n| body         | mixed  | []            | Request body          |\n| version      | string | '1.1'         | HTTP protocol version |\n| serverParams | array  | []            | Server parameters     |\n\n### Methods\n* getAttribute(name: string, [default: mixed = null]): mixed|null\n* getAttributes(): array\n* getBody(): StreamInterface\n* getCookieParams(): array\n* getHeader(name: string): array\n* getHeaderLine(name: string): string\n* getHeaders(): array\n* getMethod(): string\n* getParsedBody(): array|null|object\n* getProtocolVersion(): string\n* getQueryParams(): array\n* getRequestTarget(): string\n* getServerParams(): array\n* getUploadedFiles(): array\n* getUri(): UriInterface\n* hasHeader(name: string): bool\n* withAddedHeader(name: string, value: mixed): self\n* withAttribute(name: string, value: mixed): self\n* withBody(body: StreamInterface): self\n* withCookieParams(cookies: array): self\n* withHeader(name: string, value: mixed): self\n* withMethod(method: string): self\n* withoutAttribute(name: string): self\n* withoutHeader(name: string): self\n* withParsedBody(data: array|null|object): self\n* withProtocolVersion(version: string): self\n* withQueryParams(query: array): self\n* withRequestTarget(requestTarget: string): self\n* withUploadedFiles(uploadedFiles: array): self\n* withUri(uri: UriInterface, [preserveHost: bool = false]): self\n\n## Stream\n### Methods\n* __destruct(): void\n* __toString(): string\n* close(): void\n* detach(): null|resource\n* eof(): bool\n* getContents(): string\n* getMetadata([key: string|null = null]): ?array\n* getSize(): ?int\n* isReadable(): bool\n* isSeekable(): bool\n* isWritable(): bool\n* read(length: int): string\n* rewind(): void\n* seek(offset: int, [whence: int = \\SEEK_SET]): void\n* tell(): int\n* write(string: string): bool|int\n\n### Static Methods\n* create([content: string = '']): StreamInterface\n\n## UploadedFile\n### Constructor\n#### Mandatory\n| Parameter    | Type  | Description    |\n|--------------|-------|----------------|\n| streamOrFile | mixed | Stream or file |\n| size         | int   | Filesize       |\n| errorStatus  | int   | Upload errors  |\n\n#### Optionnals\n| Parameter       | Type         | Default value | Description |\n|-----------------|--------------|---------------|-------------|\n| clientFilename  | string\\|null | null          | Filename    |\n| clientMediaType | string\\|null | null          | Media type  |\n\n### Methods\n* getClientFilename(): ?string\n* getClientMediaType(): ?string\n* getError(): int\n* getSize(): ?int\n* getStream(): StreamInterface\n* getFilename(): ?string\n* moveTo(targetPath: string): void\n\n### Upload errors supported\n* UPLOAD_ERR_OK\n* UPLOAD_ERR_INI_SIZE\n* UPLOAD_ERR_FORM_SIZE\n* UPLOAD_ERR_PARTIAL\n* UPLOAD_ERR_NO_FILE\n* UPLOAD_ERR_NO_TMP_DIR\n* UPLOAD_ERR_CANT_WRITE\n* UPLOAD_ERR_EXTENSION\n\n## Uri\n### Constructor\n#### Optionnals\n| Parameter | Type   | Default value | Description |\n|-----------|--------|---------------|-------------|\n| uri       | string | ''            | Uri         |\n\n### Methods\n* __toString(): string\n* getAuthority(): string\n* getFragment(): string\n* getHost(): string\n* getPath(): string\n* getPort(): ?int\n* getQuery(): string\n* getScheme(): string\n* getUserInfo(): string\n* withFragment(fragment: string): self\n* withHost(host: string): self\n* withPath(path: string): self\n* withPort(port: int|null): self\n* withQuery(query: string): self\n* withScheme(scheme: string): self\n* withUserInfo(user: string, [password: string|null = null]): self\n\n## How to Dev\n`composer ci` for php-cs-fixer and phpunit and coverage  \n`composer lint` for php-cs-fixer  \n`composer test` for phpunit and coverage  \n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Francoud%2Fhttp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Francoud%2Fhttp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Francoud%2Fhttp/lists"}