<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[15285] trunk/wp-includes/class-http.php:
Some coding standards cleanups for WP_HTTP.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/15285">15285</a></dd>
<dt>Author</dt> <dd>dd32</dd>
<dt>Date</dt> <dd>2010-06-19 07:02:09 +0000 (Sat, 19 Jun 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Some coding standards cleanups for WP_HTTP. Props hakre for initial patch. See <a href="http://trac.wordpress.org/ticket/13897">#13897</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludesclasshttpphp">trunk/wp-includes/class-http.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludesclasshttpphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/class-http.php (15284 => 15285)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/class-http.php        2010-06-19 06:54:21 UTC (rev 15284)
+++ trunk/wp-includes/class-http.php        2010-06-19 07:02:09 UTC (rev 15285)
</span><span class="lines">@@ -238,39 +238,39 @@
</span><span class="cx">                 if ( false !== $pre )
</span><span class="cx">                         return $pre;
</span><span class="cx">
</span><del>-                $arrURL = parse_url($url);
</del><ins>+                $arrURL = parse_url( $url );
</ins><span class="cx">
</span><span class="cx">                 if ( empty( $url ) || empty( $arrURL['scheme'] ) )
</span><span class="cx">                         return new WP_Error('http_request_failed', __('A valid URL was not provided.'));
</span><span class="cx">
</span><span class="cx">                 if ( $this->block_request( $url ) )
</span><del>-                        return new WP_Error('http_request_failed', __('User has blocked requests through HTTP.'));
</del><ins>+                        return new WP_Error( 'http_request_failed', __( 'User has blocked requests through HTTP.' ) );
</ins><span class="cx">
</span><span class="cx">                 // Determine if this is a https call and pass that on to the transport functions
</span><span class="cx">                 // so that we can blacklist the transports that do not support ssl verification
</span><span class="cx">                 $r['ssl'] = $arrURL['scheme'] == 'https' || $arrURL['scheme'] == 'ssl';
</span><span class="cx">
</span><span class="cx">                 // Determine if this request is to OUR install of WordPress
</span><del>-                $homeURL = parse_url( get_bloginfo('url') );
</del><ins>+                $homeURL = parse_url( get_bloginfo( 'url' ) );
</ins><span class="cx">                 $r['local'] = $homeURL['host'] == $arrURL['host'] || 'localhost' == $arrURL['host'];
</span><del>-                unset($homeURL);
</del><ins>+                unset( $homeURL );
</ins><span class="cx">
</span><span class="cx">                 if ( is_null( $r['headers'] ) )
</span><span class="cx">                         $r['headers'] = array();
</span><span class="cx">
</span><del>-                if ( ! is_array($r['headers']) ) {
-                        $processedHeaders = WP_Http::processHeaders($r['headers']);
</del><ins>+                if ( ! is_array( $r['headers'] ) ) {
+                        $processedHeaders = WP_Http::processHeaders( $r['headers'] );
</ins><span class="cx">                         $r['headers'] = $processedHeaders['headers'];
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                if ( isset($r['headers']['User-Agent']) ) {
</del><ins>+                if ( isset( $r['headers']['User-Agent'] ) ) {
</ins><span class="cx">                         $r['user-agent'] = $r['headers']['User-Agent'];
</span><del>-                        unset($r['headers']['User-Agent']);
</del><ins>+                        unset( $r['headers']['User-Agent'] );
</ins><span class="cx">                 }
</span><span class="cx">
</span><del>-                if ( isset($r['headers']['user-agent']) ) {
</del><ins>+                if ( isset( $r['headers']['user-agent'] ) ) {
</ins><span class="cx">                         $r['user-agent'] = $r['headers']['user-agent'];
</span><del>-                        unset($r['headers']['user-agent']);
</del><ins>+                        unset( $r['headers']['user-agent'] );
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 // Construct Cookie: header if any cookies are set
</span><span class="lines">@@ -283,42 +283,42 @@
</span><span class="cx">                         // Some servers fail when sending content without the content-length header being set.
</span><span class="cx">                         // Also, to fix another bug, we only send when doing POST and PUT and the content-length
</span><span class="cx">                         // header isn't already set.
</span><del>-                        if( ($r['method'] == 'POST' || $r['method'] == 'PUT') && ! isset($r['headers']['Content-Length']) )
</del><ins>+                        if ( ($r['method'] == 'POST' || $r['method'] == 'PUT') && ! isset( $r['headers']['Content-Length'] ) )
</ins><span class="cx">                                 $r['headers']['Content-Length'] = 0;
</span><span class="cx">
</span><span class="cx">                         // The method is ambiguous, because we aren't talking about HTTP methods, the "get" in
</span><span class="cx">                         // this case is simply that we aren't sending any bodies and to get the transports that
</span><span class="cx">                         // don't support sending bodies along with those which do.
</span><del>-                        $transports = WP_Http::_getTransport($r);
</del><ins>+                        $transports = WP_Http::_getTransport( $r );
</ins><span class="cx">                 } else {
</span><span class="cx">                         if ( is_array( $r['body'] ) || is_object( $r['body'] ) ) {
</span><span class="cx">                                 if ( ! version_compare(phpversion(), '5.1.2', '>=') )
</span><del>-                                        $r['body'] = _http_build_query($r['body'], null, '&');
</del><ins>+                                        $r['body'] = _http_build_query( $r['body'], null, '&' );
</ins><span class="cx">                                 else
</span><del>-                                        $r['body'] = http_build_query($r['body'], null, '&');
-                                $r['headers']['Content-Type'] = 'application/x-www-form-urlencoded; charset=' . get_option('blog_charset');
-                                $r['headers']['Content-Length'] = strlen($r['body']);
</del><ins>+                                        $r['body'] = http_build_query( $r['body'], null, '&' );
+                                $r['headers']['Content-Type'] = 'application/x-www-form-urlencoded; charset=' . get_option( 'blog_charset' );
+                                $r['headers']['Content-Length'] = strlen( $r['body'] );
</ins><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         if ( ! isset( $r['headers']['Content-Length'] ) && ! isset( $r['headers']['content-length'] ) )
</span><del>-                                $r['headers']['Content-Length'] = strlen($r['body']);
</del><ins>+                                $r['headers']['Content-Length'] = strlen( $r['body'] );
</ins><span class="cx">
</span><span class="cx">                         // The method is ambiguous, because we aren't talking about HTTP methods, the "post" in
</span><span class="cx">                         // this case is simply that we are sending HTTP body and to get the transports that do
</span><span class="cx">                         // support sending the body. Not all do, depending on the limitations of the PHP core
</span><span class="cx">                         // limitations.
</span><del>-                        $transports = WP_Http::_postTransport($r);
</del><ins>+                        $transports = WP_Http::_postTransport( $r );
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 do_action( 'http_api_debug', $transports, 'transports_list' );
</span><span class="cx">
</span><span class="cx">                 $response = array( 'headers' => array(), 'body' => '', 'response' => array('code' => false, 'message' => false), 'cookies' => array() );
</span><span class="cx">                 foreach ( (array) $transports as $transport ) {
</span><del>-                        $response = $transport->request($url, $r);
</del><ins>+                        $response = $transport->request( $url, $r );
</ins><span class="cx">
</span><del>-                        do_action( 'http_api_debug', $response, 'response', get_class($transport) );
</del><ins>+                        do_action( 'http_api_debug', $response, 'response', get_class( $transport ) );
</ins><span class="cx">
</span><del>-                        if ( ! is_wp_error($response) )
</del><ins>+                        if ( ! is_wp_error( $response ) )
</ins><span class="cx">                                 return apply_filters( 'http_response', $response, $r, $url );
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="lines">@@ -621,7 +621,7 @@
</span><span class="cx">                 if ( isset($r['headers']['User-Agent']) ) {
</span><span class="cx">                         $r['user-agent'] = $r['headers']['User-Agent'];
</span><span class="cx">                         unset($r['headers']['User-Agent']);
</span><del>-                } else if( isset($r['headers']['user-agent']) ) {
</del><ins>+                } else if ( isset($r['headers']['user-agent']) ) {
</ins><span class="cx">                         $r['user-agent'] = $r['headers']['user-agent'];
</span><span class="cx">                         unset($r['headers']['user-agent']);
</span><span class="cx">                 }
</span><span class="lines">@@ -973,7 +973,7 @@
</span><span class="cx">                 if ( isset($r['headers']['User-Agent']) ) {
</span><span class="cx">                         $r['user-agent'] = $r['headers']['User-Agent'];
</span><span class="cx">                         unset($r['headers']['User-Agent']);
</span><del>-                } else if( isset($r['headers']['user-agent']) ) {
</del><ins>+                } else if ( isset($r['headers']['user-agent']) ) {
</ins><span class="cx">                         $r['user-agent'] = $r['headers']['user-agent'];
</span><span class="cx">                         unset($r['headers']['user-agent']);
</span><span class="cx">                 }
</span><span class="lines">@@ -1146,7 +1146,7 @@
</span><span class="cx">                 if ( isset($r['headers']['User-Agent']) ) {
</span><span class="cx">                         $r['user-agent'] = $r['headers']['User-Agent'];
</span><span class="cx">                         unset($r['headers']['User-Agent']);
</span><del>-                } else if( isset($r['headers']['user-agent']) ) {
</del><ins>+                } else if ( isset($r['headers']['user-agent']) ) {
</ins><span class="cx">                         $r['user-agent'] = $r['headers']['user-agent'];
</span><span class="cx">                         unset($r['headers']['user-agent']);
</span><span class="cx">                 }
</span><span class="lines">@@ -1296,7 +1296,7 @@
</span><span class="cx">                 if ( isset($r['headers']['User-Agent']) ) {
</span><span class="cx">                         $r['user-agent'] = $r['headers']['User-Agent'];
</span><span class="cx">                         unset($r['headers']['User-Agent']);
</span><del>-                } else if( isset($r['headers']['user-agent']) ) {
</del><ins>+                } else if ( isset($r['headers']['user-agent']) ) {
</ins><span class="cx">                         $r['user-agent'] = $r['headers']['user-agent'];
</span><span class="cx">                         unset($r['headers']['user-agent']);
</span><span class="cx">                 }
</span></span></pre>
</div>
</div>
</body>
</html>