{"id":16310147,"url":"https://github.com/grinnz/http-simple","last_synced_at":"2025-10-17T04:34:52.405Z","repository":{"id":56836788,"uuid":"173224560","full_name":"Grinnz/HTTP-Simple","owner":"Grinnz","description":"HTTP::Simple - Simple procedural interface to HTTP::Tiny","archived":false,"fork":false,"pushed_at":"2019-05-08T15:21:48.000Z","size":40,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-16T08:14:22.650Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://metacpan.org/pod/HTTP::Simple","language":"Perl","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/Grinnz.png","metadata":{"files":{"readme":"README.pod","changelog":"Changes","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-01T02:56:40.000Z","updated_at":"2021-02-08T17:58:10.000Z","dependencies_parsed_at":"2022-09-08T05:11:22.576Z","dependency_job_id":null,"html_url":"https://github.com/Grinnz/HTTP-Simple","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Grinnz%2FHTTP-Simple","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Grinnz%2FHTTP-Simple/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Grinnz%2FHTTP-Simple/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Grinnz%2FHTTP-Simple/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Grinnz","download_url":"https://codeload.github.com/Grinnz/HTTP-Simple/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248750127,"owners_count":21155687,"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":[],"created_at":"2024-10-10T21:23:56.306Z","updated_at":"2025-10-17T04:34:52.311Z","avatar_url":"https://github.com/Grinnz.png","language":"Perl","readme":"=pod\n\n=head1 NAME\n\nHTTP::Simple - Simple procedural interface to HTTP::Tiny\n\n=head1 SYNOPSIS\n\n  perl -MHTTP::Simple -e'getprint(shift)' 'https://example.com'\n\n  use HTTP::Simple;\n\n  my $content = get 'https://example.com';\n\n  if (mirror('https://example.com', '/path/to/file.html') == 304) { ... }\n\n  if (is_success(getprint 'https://example.com')) { ... }\n\n  postform('https://example.com', {foo =\u003e ['bar', 'baz']});\n\n  postjson('https://example.com', [{bar =\u003e 'baz'}]);\n\n  postfile('https://example.com', '/path/to/file.png');\n\n=head1 DESCRIPTION\n\nThis module is a wrapper of L\u003cHTTP::Tiny\u003e that provides simplified functions\nfor performing HTTP requests in a similar manner to L\u003cLWP::Simple\u003e, but with\nslightly more useful error handling. For full control of the request process\nand response handling, use L\u003cHTTP::Tiny\u003e directly.\n\nL\u003cIO::Socket::SSL\u003e is required for HTTPS requests with L\u003cHTTP::Tiny\u003e.\n\nRequest methods that return the body content of the response will return a byte\nstring suitable for directly printing, but that may need to be\nL\u003cdecoded|Encode/decode\u003e for text operations.\n\nThe L\u003cHTTP::Tiny\u003e object used by these functions to make requests can be\naccessed as C\u003c$HTTP::Simple::UA\u003e (for example, to configure the timeout, or\nreplace it with a compatible object like L\u003cHTTP::Tinyish\u003e).\n\nThe JSON encoder used by the JSON functions can be accessed as\nC\u003c$HTTP::Simple::JSON\u003e, and defaults to a L\u003cCpanel::JSON::XS\u003e object if\nL\u003cCpanel::JSON::XS\u003e 4.11+ is installed, and otherwise a L\u003cJSON::PP\u003e object. If\nreplaced with a new object, it should have UTF-8 encoding/decoding enabled\n(usually the C\u003cutf8\u003e option). If it is set to a string, it will be used as a\nmodule name that is expected to have C\u003cdecode_json\u003e and C\u003cencode_json\u003e\nfunctions.\n\n=head1 FUNCTIONS\n\nAll functions are exported by default. Functions can also be requested\nindividually or with the tags C\u003c:request\u003e, C\u003c:status\u003e, or C\u003c:all\u003e.\n\n=head2 get\n\n  my $contents = get($url);\n\nRetrieves the document at the given URL with a GET request and returns it as a\nbyte string. Throws an exception on connection or HTTP errors.\n\n=head2 getjson\n\n  my $data = getjson($url);\n\nRetrieves the JSON document at the given URL with a GET request and decodes it\nfrom JSON to a Perl structure. Throws an exception on connection, HTTP, or JSON\nerrors.\n\n=head2 head\n\n  my $headers = head($url);\n\nRetrieves the headers at the given URL with a HEAD request and returns them as\na hash reference. Header field names are normalized to lower case, and values\nmay be an array reference if the header is repeated. Throws an exception on\nconnection or HTTP errors.\n\n=head2 getprint\n\n  my $status = getprint($url);\n\nRetrieves the document at the given URL with a GET request and prints it as it\nis received. Returns the HTTP status code. Throws an exception on connection\nerrors.\n\n=head2 getstore\n\n  my $status = getstore($url, $path);\n\nRetrieves the document at the given URL with a GET request and stores it to the\ngiven file path. Returns the HTTP status code. Throws an exception on\nconnection or filesystem errors.\n\n=head2 mirror\n\n  my $status = mirror($url, $path);\n\nRetrieves the document at the given URL with a GET request and mirrors it to\nthe given file path, using the C\u003cIf-Modified-Since\u003e headers to short-circuit if\nthe file exists and is new enough, and the C\u003cLast-Modified\u003e header to set its\nmodification time. Returns the HTTP status code. Throws an exception on\nconnection, HTTP, or filesystem errors.\n\n=head2 postform\n\n  my $contents = postform($url, $form);\n\nSends a POST request to the given URL with the given hash or array reference of\nform data serialized to C\u003capplication/x-www-form-urlencoded\u003e. Returns the\nresponse body as a byte string. Throws an exception on connection or HTTP\nerrors.\n\n=head2 postjson\n\n  my $contents = postjson($url, $data);\n\nSends a POST request to the given URL with the given data structure encoded to\nJSON. Returns the response body as a byte string. Throws an exception on\nconnection, HTTP, or JSON errors.\n\n=head2 postfile\n\n  my $contents = postfile($url, $path);\n  my $contents = postfile($url, $path, $content_type);\n\nSends a POST request to the given URL, streaming the contents of the given\nfile. The content type is passed as C\u003capplication/octet-stream\u003e if not\nspecified. Returns the response body as a byte string. Throws an exception on\nconnection, HTTP, or filesystem errors.\n\n=head2 is_info\n\n  my $bool = is_info($status);\n\nReturns true if the status code indicates an informational response (C\u003c1xx\u003e).\n\n=head2 is_success\n\n  my $bool = is_success($status);\n\nReturns true if the status code indicates a successful response (C\u003c2xx\u003e).\n\n=head2 is_redirect\n\n  my $bool = is_redirect($status);\n\nReturns true if the status code indicates a redirection response (C\u003c3xx\u003e).\n\n=head2 is_error\n\n  my $bool = is_error($status);\n\nReturns true if the status code indicates an error response (C\u003c4xx\u003e or C\u003c5xx\u003e).\n\n=head2 is_client_error\n\n  my $bool = is_client_error($status);\n\nReturns true if the status code indicates a client error response (C\u003c4xx\u003e).\n\n=head2 is_server_error\n\n  my $bool = is_server_error($status);\n\nReturns true if the status code indicates a server error response (C\u003c5xx\u003e).\n\n=head1 BUGS\n\nReport any issues on the public bugtracker.\n\n=head1 AUTHOR\n\nDan Book \u003cdbook@cpan.org\u003e\n\n=head1 COPYRIGHT AND LICENSE\n\nThis software is Copyright (c) 2019 by Dan Book.\n\nThis is free software, licensed under:\n\n  The Artistic License 2.0 (GPL Compatible)\n\n=head1 SEE ALSO\n\nL\u003cLWP::Simple\u003e, L\u003cHTTP::Tinyish\u003e, L\u003cojo\u003e\n\n=cut\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrinnz%2Fhttp-simple","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrinnz%2Fhttp-simple","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrinnz%2Fhttp-simple/lists"}