Ignore:
Timestamp:
2011/10/25 00:02:55 (12 years ago)
Author:
Seasoft
Message:

#1521 (PEAR::SOAP 配布と異なる部分がある)

  • 新しいバージョンの配布ファイルを上書きすることで解決

#1522 (PEAR::SOAP をバージョンアップ)

  • 0.11.0 -> 0.12.0
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_11-dev/data/module/SOAP/Transport/HTTP.php

    r20119 r21299  
    2525 * 
    2626 * @package  SOAP 
    27  * @category Web_Services 
     27 * @category Web Services 
    2828 */ 
    2929 
     
    327327    function _parseResponse() 
    328328    { 
    329         if (preg_match("/^(.*?)\r?\n\r?\n(.*)/s", 
     329        if (!preg_match("/^(.*?)\r?\n\r?\n(.*)/s", 
    330330                       $this->incoming_payload, 
    331331                       $match)) { 
    332             $this->response = $match[2]; 
    333             // Find the response error, some servers response with 500 for 
    334             // SOAP faults. 
    335             $this->_parseHeaders($match[1]); 
    336  
    337             list(, $code, $msg) = sscanf($this->result_headers[0], '%s %s %s'); 
    338             unset($this->result_headers[0]); 
    339  
    340             switch($code) { 
    341                 case 100: // Continue 
    342                     $this->incoming_payload = $match[2]; 
    343                     return $this->_parseResponse(); 
    344                 case 400: 
    345                     $this->_raiseSoapFault("HTTP Response $code Bad Request"); 
    346                     return false; 
    347                     break; 
    348                 case 401: 
    349                     $this->_raiseSoapFault("HTTP Response $code Authentication Failed"); 
    350                     return false; 
    351                     break; 
    352                 case 403: 
    353                     $this->_raiseSoapFault("HTTP Response $code Forbidden"); 
    354                     return false; 
    355                     break; 
    356                 case 404: 
    357                     $this->_raiseSoapFault("HTTP Response $code Not Found"); 
    358                     return false; 
    359                     break; 
    360                 case 407: 
    361                     $this->_raiseSoapFault("HTTP Response $code Proxy Authentication Required"); 
    362                     return false; 
    363                     break; 
    364                 case 408: 
    365                     $this->_raiseSoapFault("HTTP Response $code Request Timeout"); 
    366                     return false; 
    367                     break; 
    368                 case 410: 
    369                     $this->_raiseSoapFault("HTTP Response $code Gone"); 
    370                     return false; 
    371                     break; 
    372                 default: 
    373                     if ($code >= 400 && $code < 500) { 
    374                         $this->_raiseSoapFault("HTTP Response $code Not Found, Server message: $msg"); 
    375                         return false; 
    376                     } 
    377             } 
    378  
    379             $this->_parseEncoding($match[1]); 
    380  
    381             if ($this->result_content_type == 'application/dime') { 
    382                 // XXX quick hack insertion of DIME 
    383                 if (PEAR::isError($this->_decodeDIMEMessage($this->response, $this->headers, $this->attachments))) { 
    384                     // _decodeDIMEMessage already raised $this->fault 
     332            $this->_raiseSoapFault('Invalid HTTP Response'); 
     333            return false; 
     334        } 
     335 
     336        $this->response = $match[2]; 
     337        // Find the response error, some servers response with 500 for 
     338        // SOAP faults. 
     339        $this->_parseHeaders($match[1]); 
     340 
     341        list(, $code, $msg) = sscanf($this->result_headers[0], '%s %s %s'); 
     342        unset($this->result_headers[0]); 
     343 
     344        switch($code) { 
     345            case 100: // Continue 
     346                $this->incoming_payload = $match[2]; 
     347                return $this->_parseResponse(); 
     348            case 200: 
     349            case 202: 
     350                $this->incoming_payload = trim($match[2]); 
     351                if (!strlen($this->incoming_payload)) { 
     352                    /* Valid one-way message response. */ 
     353                    return true; 
     354                } 
     355                break; 
     356            case 400: 
     357                $this->_raiseSoapFault("HTTP Response $code Bad Request"); 
     358                return false; 
     359            case 401: 
     360                $this->_raiseSoapFault("HTTP Response $code Authentication Failed"); 
     361                return false; 
     362            case 403: 
     363                $this->_raiseSoapFault("HTTP Response $code Forbidden"); 
     364                return false; 
     365            case 404: 
     366                $this->_raiseSoapFault("HTTP Response $code Not Found"); 
     367                return false; 
     368            case 407: 
     369                $this->_raiseSoapFault("HTTP Response $code Proxy Authentication Required"); 
     370                return false; 
     371            case 408: 
     372                $this->_raiseSoapFault("HTTP Response $code Request Timeout"); 
     373                return false; 
     374            case 410: 
     375                $this->_raiseSoapFault("HTTP Response $code Gone"); 
     376                return false; 
     377            default: 
     378                if ($code >= 400 && $code < 500) { 
     379                    $this->_raiseSoapFault("HTTP Response $code Not Found, Server message: $msg"); 
    385380                    return false; 
    386381                } 
    387                 $this->result_content_type = $this->headers['content-type']; 
    388             } elseif (stristr($this->result_content_type, 'multipart/related')) { 
    389                 $this->response = $this->incoming_payload; 
    390                 if (PEAR::isError($this->_decodeMimeMessage($this->response, $this->headers, $this->attachments))) { 
    391                     // _decodeMimeMessage already raised $this->fault 
    392                     return false; 
    393                 } 
    394             } elseif ($this->result_content_type != 'text/xml') { 
    395                 $this->_raiseSoapFault($this->response); 
    396                 return false; 
    397             } 
    398             // if no content, return false 
    399             return strlen($this->response) > 0; 
    400         } 
    401         $this->_raiseSoapFault('Invalid HTTP Response'); 
    402         return false; 
     382                break; 
     383        } 
     384 
     385        $this->_parseEncoding($match[1]); 
     386 
     387        if ($this->result_content_type == 'application/dime') { 
     388            // XXX quick hack insertion of DIME 
     389            if (PEAR::isError($this->_decodeDIMEMessage($this->response, $this->headers, $this->attachments))) { 
     390                // _decodeDIMEMessage already raised $this->fault 
     391                return false; 
     392            } 
     393            $this->result_content_type = $this->headers['content-type']; 
     394        } elseif (stristr($this->result_content_type, 'multipart/related')) { 
     395            $this->response = $this->incoming_payload; 
     396            if (PEAR::isError($this->_decodeMimeMessage($this->response, $this->headers, $this->attachments))) { 
     397                // _decodeMimeMessage already raised $this->fault 
     398                return false; 
     399            } 
     400        } elseif ($this->result_content_type != 'text/xml') { 
     401            $this->_raiseSoapFault($this->response); 
     402            return false; 
     403        } 
     404 
     405        // if no content, return false 
     406        return strlen($this->response) > 0; 
    403407    } 
    404408 
     
    558562        } 
    559563 
    560         if (!isset($options['soapaction'])) { 
    561             $options['soapaction'] = ''; 
    562         } 
    563         if (!isset($options['headers']['Content-Type'])) { 
    564            $options['headers']['Content-Type'] = 'text/xml'; 
    565         } 
    566         curl_setopt($ch, CURLOPT_HTTPHEADER, 
    567                     array('Content-Type: ' . $options['headers']['Content-Type'] 
    568                          . ';charset=' . $this->encoding, 
    569                           'SOAPAction: "' . $options['soapaction'] . '"')); 
    570         curl_setopt($ch, CURLOPT_USERAGENT, 
    571                     $this->_userAgent); 
     564        $headers = array(); 
     565        $action = isset($options['soapaction']) ? $options['soapaction'] : ''; 
     566        $headers['Content-Type'] = "text/xml; charset=$this->encoding"; 
     567        $headers['SOAPAction'] = '"' . $action . '"'; 
     568        if (isset($options['headers'])) { 
     569            $headers = array_merge($headers, $options['headers']); 
     570        } 
     571        foreach ($headers as $header => $value) { 
     572            $headers[$header] = $header . ': ' . $value; 
     573        } 
     574        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 
     575        curl_setopt($ch, CURLOPT_USERAGENT, $this->_userAgent); 
    572576 
    573577        if ($this->timeout) { 
Note: See TracChangeset for help on using the changeset viewer.