geofffranks / json-api

A perl module to simplify interaction with JSON APIs
Other
6 stars 6 forks source link

Request and Response headers not accessible #1

Closed tlhackque closed 7 years ago

tlhackque commented 7 years ago

It would be useful for the response headers to be available.

For example:

It looks like http_req() can save $res in $self. This, along with a suitable access method would solve this. e.g. $resp = $api->response() (return the whole response object) and/or $resp = $api->headers() (return a hashref or specific header);

Likewise, user-provided request headers can be useful. E.g. adding "If-Modified", 'If-None_Match" and/or "If-SSL-Cert-Subject" for mirroring/server verification.

Perhaps an optional 3rd argument to get/put/post/delete could be a hashref that's merged with $headers in http_req(). e.g. $headers = (%$headers, %$reqhdrs) if( defined $reqhdrs);

These examples aren't an exhaustive list.

Of course, there are other approaches...

Thanks for your consideration.

geofffranks commented 7 years ago

This all seems like good stuff. If you want to make a PR for it, I'd be happy to review!

tlhackque commented 7 years ago

I'll submit a PR shortly.

Why are you licensing this under GPL? It's a library, so it should at least be LGPL - or the Perl Artistic license. Unless you want to restrict usage.