Changeset 8f2c6c5
- Timestamp:
- 01/05/12 11:37:12 (5 months ago)
- Branches:
- master
- Children:
- 8bea7a4, 008aa2e
- Parents:
- 2d6c03b
- git-author:
- Michiel Rook <mrook@…> (01/05/12 11:37:12)
- git-committer:
- Michiel Rook <mrook@…> (01/05/12 11:37:12)
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
classes/phing/tasks/ext/HttpGetTask.php
- Property mode changed from 100644 to 100755
r84b1411 r8f2c6c5 46 46 */ 47 47 protected $dir = null; 48 48 49 /** 50 * Holds the proxy 51 * 52 * @var string 53 */ 54 protected $_proxy = null; 49 55 50 56 /** … … 55 61 public function init() 56 62 { 57 require_once 'HTTP/Request2.php'; 63 @include_once 'HTTP/Request2.php'; 64 65 if (! class_exists('HTTP_Request2')) { 66 throw new BuildException( 67 'HttpRequestTask depends on HTTP_Request2 being installed ' 68 . 'and on include_path.', 69 $this->getLocation() 70 ); 71 } 58 72 } 59 73 … … 73 87 throw new BuildException("Missing attribute 'dir'"); 74 88 } 89 90 $config = array(); 91 if (isset($this->_proxy) && $url = parse_url($this->_proxy)) { 92 $config['proxy_user'] = $url['user']; 93 $config['proxy_password'] = $url['pass']; 94 $config['proxy_host'] = $url['host']; 95 $config['proxy_port'] = $url['port']; 96 } 75 97 76 $this->log("Fetching " . $this->url);98 $this->log("Fetching " . $this->url); 77 99 78 $request = new HTTP_Request2($this->url); 79 $response = $request->send(); 80 if ($response->getStatus() != 200) { 81 throw new BuildException("Request unsuccessfull. Response from server: " . $response->getStatus() . " " . $response->getReasonPhrase()); 82 } 83 $content = $response->getBody(); 84 if ($this->filename) { 85 $filename = $this->filename; 86 } elseif ($disposition = $response->getHeader('content-disposition') 87 && 0 == strpos($disposition, 'attachment') 88 && preg_match('/filename="([^"]+)"/', $disposition, $m)) { 89 $filename = basename($m[1]); 90 } else { 91 $filename = basename(parse_url($this->url, PHP_URL_PATH)); 92 } 93 94 if (!is_writable($this->dir)) { 95 throw new BuildException("Cannot write to directory: " . $this->dir); 96 } 97 $filename = $this->dir . "/" . $filename; 98 file_put_contents($filename, $content); 99 $this->log("Contents from " . $this->url . " saved to $filename"); 100 $request = new HTTP_Request2($this->url, $config); 101 $response = $request->send(); 102 if ($response->getStatus() != 200) { 103 throw new BuildException("Request unsuccessful. Response from server: " . $response->getStatus() . " " . $response->getReasonPhrase()); 104 } 105 106 $content = $response->getBody(); 107 if ($this->filename) { 108 $filename = $this->filename; 109 } elseif ($disposition = $response->getHeader('content-disposition') 110 && 0 == strpos($disposition, 'attachment') 111 && preg_match('/filename="([^"]+)"/', $disposition, $m)) { 112 $filename = basename($m[1]); 113 } else { 114 $filename = basename(parse_url($this->url, PHP_URL_PATH)); 115 } 116 117 if (!is_writable($this->dir)) { 118 throw new BuildException("Cannot write to directory: " . $this->dir); 119 } 120 121 $filename = $this->dir . "/" . $filename; 122 file_put_contents($filename, $content); 123 124 $this->log("Contents from " . $this->url . " saved to $filename"); 100 125 } 101 126 … … 112 137 } 113 138 139 /** 140 * Sets the proxy 141 * 142 * @param string $proxy 143 */ 144 public function setProxy($proxy) { 145 $this->_proxy = $proxy; 146 } 114 147 } -
classes/phing/tasks/ext/HttpRequestTask.php
- Property mode changed from 100644 to 100755
rf410e6e r8f2c6c5 42 42 43 43 /** 44 * Holds the proxy 45 * 46 * @var string 47 */ 48 protected $_proxy = null; 49 50 /** 44 51 * Holds the regular expression that should match the response 45 52 * … … 115 122 116 123 /** 124 * Sets the proxy 125 * 126 * @param string $proxy 127 */ 128 public function setProxy($proxy) { 129 $this->_proxy = $proxy; 130 } 131 132 /** 117 133 * Sets the response regex 118 134 * … … 240 256 } 241 257 242 $request = new HTTP_Request2($this->_url); 258 $config = array(); 259 if (isset($this->_proxy) && $url = parse_url($this->_proxy)) { 260 $config['proxy_user'] = $url['user']; 261 $config['proxy_password'] = $url['pass']; 262 $config['proxy_host'] = $url['host']; 263 $config['proxy_port'] = $url['port']; 264 } 265 266 $request = new HTTP_Request2($this->_url, $config); 243 267 244 268 // set the authentication data -
docs/phing_guide/book/chapters/appendixes/AppendixC-OptionalTasks.html
- Property mode changed from 100644 to 100755
r582f22d r8f2c6c5 2129 2129 <td>No</td> 2130 2130 </tr> 2131 </tbody> 2131 <tr> 2132 <td>proxy</td> 2133 <td>String</td> 2134 <td>The proxy to use, such as <em>http://user:password@hostname:port/</em></td> 2135 <td>n/a</td> 2136 <td>No</td> 2137 </tr> 2138 </tbody> 2132 2139 </table> 2133 2140 <h3>Example</h3> … … 2162 2169 <td>Yes</td> 2163 2170 </tr> 2171 <tr> 2172 <td>proxy</td> 2173 <td>String</td> 2174 <td>The proxy to use, such as <em>http://user:password@hostname:port/</em></td> 2175 <td>n/a</td> 2176 <td>No</td> 2177 </tr> 2164 2178 <tr> 2165 2179 <td>responseRegex</td>
Note: See TracChangeset
for help on using the changeset viewer.
