90 if ( is_array( $this->postData ) ) {
94 if ( $this->parsedUrl[
'scheme'] !=
'http'
95 && $this->parsedUrl[
'scheme'] !=
'https' ) {
96 $this->status->fatal(
'http-invalid-scheme', $this->parsedUrl[
'scheme'] );
99 $this->reqHeaders[
'Accept'] =
"*/*";
100 $this->reqHeaders[
'Connection'] =
'Close';
101 if ( $this->method ==
'POST' ) {
103 $this->reqHeaders[
'Content-Length'] = strlen( $this->postData );
104 if ( !isset( $this->reqHeaders[
'Content-Type'] ) ) {
105 $this->reqHeaders[
'Content-Type'] =
"application/x-www-form-urlencoded";
112 'method' => $this->method,
114 'protocol_version' =>
'1.1',
115 'max_redirects' => $this->followRedirects ? $this->maxRedirects : 0,
116 'ignore_errors' =>
true,
117 'timeout' => $this->timeout,
119 'curl_verify_ssl_host' => $this->sslVerifyHost ? 2 : 0,
120 'curl_verify_ssl_peer' => $this->sslVerifyCert,
123 'verify_peer' => $this->sslVerifyCert,
124 'SNI_enabled' =>
true,
125 'ciphers' =>
'HIGH:!SSLv2:!SSLv3:-ADH:-kDH:-kECDH:-DSS',
126 'disable_compression' =>
true,
130 if ( $this->proxy ) {
132 $options[
'http'][
'request_fulluri'] =
true;
135 if ( $this->postData ) {
136 $options[
'http'][
'content'] = $this->postData;
139 if ( $this->sslVerifyHost ) {
142 if ( version_compare( PHP_VERSION,
'5.6.0',
'>=' ) ) {
143 $options[
'ssl'][
'peer_name'] = $this->parsedUrl[
'host'];
145 $options[
'ssl'][
'CN_match'] = $this->parsedUrl[
'host'];
153 $this->headerList = [];
159 if ( $this->profiler ) {
160 $profileSection = $this->profiler->scopedProfileIn(
161 __METHOD__ .
'-' . $this->profileName
166 $this->fopenErrors = [];
167 set_error_handler( [ $this,
'errorHandler' ] );
169 restore_error_handler();
177 if ( isset(
$options[
'ssl'][
'CN_match'] )
178 && (
$options[
'ssl'][
'CN_match'] ===
'commons.wikimedia.org'
179 ||
$options[
'ssl'][
'CN_match'] ===
'upload.wikimedia.org' )
181 $options[
'ssl'][
'CN_match'] =
'en.wikipedia.org';
188 $result = stream_get_meta_data( $fh );
189 $this->headerList = $result[
'wrapper_data'];
192 if ( !$this->followRedirects ) {
196 # Handle manual redirection
197 if ( !$this->
isRedirect() || $reqCount > $this->maxRedirects ) {
200 # Check security of URL
204 $this->logger->debug( __METHOD__ .
": insecure redirection\n" );
208 if ( $this->profiler ) {
209 $this->profiler->scopedProfileOut( $profileSection );
214 if ( $fh ===
false ) {
215 if ( $this->fopenErrors ) {
216 $this->logger->warning( __CLASS__
217 .
': error opening connection: {errstr1}', $this->fopenErrors );
219 $this->status->fatal(
'http-request-error' );
220 return Status::wrap( $this->status );
223 if ( $result[
'timed_out'] ) {
224 $this->status->fatal(
'http-timed-out', $this->url );
225 return Status::wrap( $this->status );
230 if ( $this->status->isOK() || (
int)$this->respStatus >= 300 ) {
231 while ( !feof( $fh ) ) {
232 $buf = fread( $fh, 8192 );
234 if ( $buf ===
false ) {
235 $this->status->fatal(
'http-read-error' );
239 if ( strlen( $buf ) ) {
240 call_user_func( $this->callback, $fh, $buf );
246 return Status::wrap( $this->status );