Auth_OpenID_GenericConsumer::_httpResponseToMessage PHP Method

_httpResponseToMessage() static public method

Adapt a POST response to a Message.
static public _httpResponseToMessage ( $response, $server_url )
$response Result of a POST to an OpenID endpoint.
    static function _httpResponseToMessage($response, $server_url)
    {
        // Should this function be named Message.fromHTTPResponse instead?
        $response_message = Auth_OpenID_Message::fromKVForm($response->body);
        if ($response->status == 400) {
            return Auth_OpenID_ServerErrorContainer::fromMessage($response_message);
        } else {
            if ($response->status != 200 and $response->status != 206) {
                return null;
            }
        }
        return $response_message;
    }

Usage Example

示例#1
0
 function test_500()
 {
     // 500 as an example of any non-200, non-400 code.
     $response = new Auth_Yadis_HTTPResponse();
     $response->status = 500;
     $response->body = "foo:bar\nbaz:quux\n";
     $result = Auth_OpenID_GenericConsumer::_httpResponseToMessage($response, $this->server_url);
     $this->assertTrue($result === null);
 }