Make WordPress Core

Changeset 10313


Ignore:
Timestamp:
01/05/2009 09:32:04 PM (16 years ago)
Author:
ryan
Message:

Add support for custom headers in the IXR (XML-RPC) class. Props josephscott. fixes #8145

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/class-IXR.php

    r8403 r10313  
    496496    var $path;
    497497    var $useragent;
     498    var $headers;
    498499    var $response;
    499500    var $message = false;
     
    529530        $r = "\r\n";
    530531        $request  = "POST {$this->path} HTTP/1.0$r";
    531         $request .= "Host: {$this->server}$r";
    532         $request .= "Content-Type: text/xml$r";
    533         $request .= "User-Agent: {$this->useragent}$r";
    534         $request .= "Content-length: {$length}$r$r";
     532
     533        $this->headers['Host']          = $this->server;
     534        $this->headers['Content-Type']  = 'text/xml';
     535        $this->headers['User-Agent']    = $this->useragent;
     536        $this->headers['Content-Length']= $length;
     537
     538        foreach( $this->headers as $header => $value ) {
     539            $request .= "{$header}: {$value}{$r}";
     540        }
     541        $request .= $r;
     542
    535543        $request .= $xml;
    536544        // Now send the request
     
    556564                // Check line for '200'
    557565                if (strstr($line, '200') === false) {
    558                     $this->error = new IXR_Error(-32300, 'transport error - HTTP status code was not 200');
     566                    $this->error = new IXR_Error(-32301, 'transport error - HTTP status code was not 200');
    559567                    return false;
    560568                }
Note: See TracChangeset for help on using the changeset viewer.