{"id":15984559,"url":"https://github.com/dcarbone/curl-header-extractor","last_synced_at":"2026-04-29T14:05:25.727Z","repository":{"id":56964018,"uuid":"50299634","full_name":"dcarbone/curl-header-extractor","owner":"dcarbone","description":"Utility to extract headers from PHP CURL to file request.","archived":false,"fork":false,"pushed_at":"2021-02-14T17:54:53.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-12T09:28:01.947Z","etag":null,"topics":["composer","extract-headers","php-curl"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dcarbone.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-24T17:48:52.000Z","updated_at":"2021-02-14T17:54:39.000Z","dependencies_parsed_at":"2022-08-21T05:30:12.108Z","dependency_job_id":null,"html_url":"https://github.com/dcarbone/curl-header-extractor","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/dcarbone/curl-header-extractor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcarbone%2Fcurl-header-extractor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcarbone%2Fcurl-header-extractor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcarbone%2Fcurl-header-extractor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcarbone%2Fcurl-header-extractor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dcarbone","download_url":"https://codeload.github.com/dcarbone/curl-header-extractor/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcarbone%2Fcurl-header-extractor/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32428623,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T13:34:34.882Z","status":"ssl_error","status_checked_at":"2026-04-29T13:34:29.830Z","response_time":110,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","extract-headers","php-curl"],"created_at":"2024-10-08T02:09:35.045Z","updated_at":"2026-04-29T14:05:25.710Z","avatar_url":"https://github.com/dcarbone.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# curl-header-extractor\nUtility to extract headers from PHP CURL request.\n\n# Installation\n\nWhile it is advisable to use [Composer](https://getcomposer.org/), this lib is simple enough to be used without it.\n\nComposer Require entry:\n```json\n{\n    \"dcarbone/curl-header-extractor\": \"v3.0.*\"\n}\n```\n\n# Usage\n\nThere are 3 methods available:\n\n### [getHeaderAndBody](./src/CURLHeaderExtractor.php#L168)\n\nThis method accepts a single argument that may be:\n\n- Full path to the file\n- File resource created with [fopen](http://php.net/manual/en/function.fopen.php) with at least read permissions.\n- String of response data\n\nThe response will be an array with the following structure:\n\n```php\narray(\n    // array of headers,\n    // string of body content\n);\n```\n\n#### Example: \n\n```php\nlist($headers, $body) = \\DCarbone\\CURLHeaderExtractor::getHeaderAndBody($input);\n```\n\nwhere `$headers` will be an array of headers, or NULL if no headers were found,\nand `$body` will be the entire contents of the body.\n\n#### Note:\n\nThis method CAN be very expensive to use if you are working with particularly large responses, as the end\nresult will be the entire contents of the file loaded into memory.\n\nIf you wish to extract JUST the headers, the below methods might serve you better.\n\n### [extractHeadersAndBodyStartOffset](./src/CURLHeaderExtractor.php#L81)\n\nThis method will return an array with the following structure:\n\n```php\narray(\n    // array of headers,\n    // integer representing the byte offset of the beginning of the body\n);\n```\n\n#### Example: \n\n```php\nlist($headers, $bodyByteOffset) = \\DCarbone\\CURLHeaderExtractor::extractHeadersAndBodyStartOffset($input);\n```\n\nIf no headers were seen in the file, `$headers` in the above example will be NULL and the byte offset\nwill be 0.\n\n### [removeHeadersAndMoveFile](./src/CURLHeaderExtractor.php#L102)\n\nThis method will strip the file of the headers, copy the body to a new file, and then delete the old file.\n\n#### Example:\n\n```php\n\\DCarbone\\CURLHeaderExtractor::removeHeadersAndMoveFile($file, 'my_new_filename.ext');\n```\n\nIf you executed the [extractHeadersAndBodyStartOffset](./src/CURLHeaderExtractor.php#L81) method\nalready, you may pass in the body start offset integer in as the 3rd argument.\n\n## Invoking\n\nTo make this class easier to work with as a \"helper\", it implements the \n[PHP magic method __invoke](http://php.net/manual/en/language.oop5.magic.php#object.invoke) (you\ncan see the implementation [here](./src/CURLHeaderExtractor.php#L67)).\n\nThis allows you to do something like this:\n\n```php\n$extractor = new \\DCarbone\\CURLHeaderExtractor();\n\nlist($headers, $body) = $extractor($input);\n```\n\nYou can, of course, access the other methods as you normally would any static method:\n\n```php\nlist($headers, $bodyByteOffset) = $extractor::extractHeadersAndBodyStartOffset($input);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdcarbone%2Fcurl-header-extractor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdcarbone%2Fcurl-header-extractor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdcarbone%2Fcurl-header-extractor/lists"}