Page MenuHomePhabricator

Return response headers in oauthclient->makeOAuthCall()
Open, Needs TriagePublic

Description

The oauthclient makeOAuthCall() should return response headers, e.g. to get the content type or any other header that the client may need. The easiest I think is to add an extra &$responseHeaders parameter defaulted to null - if set, use the curl_setopt($ch, CURLOPT_HEADERFUNCTION, ...) to get all response headers and add them to the array. Thanks!

See a good implementation https://stackoverflow.com/a/41135574/177275 (2nd answer) - that seem to properly parse response headers.

Event Timeline

What's the use case for needing the headers directly?

@Tgr forwarding an api call from a complex js client - if the response is a non-200, the client may decide to handle it somehow different (I assume non-200 responses are still returned in some form as content, but they won't be JSON).

Oh, right, we have a REST API now so the headers / response code will be used to communicate information.