303 | 303 | $options = array( |
304 | 304 | 'timeout' => $r['timeout'], |
305 | 305 | 'useragent' => $r['user-agent'], |
306 | 306 | 'blocking' => $r['blocking'], |
307 | 307 | 'hooks' => new Requests_Hooks(), |
308 | 308 | ); |
309 | 309 | |
310 | 310 | // Ensure redirects follow browser behaviour. |
311 | 311 | $options['hooks']->register( 'requests.before_redirect', array( get_class(), 'browser_redirect_compatibility' ) ); |
312 | 312 | |
313 | 313 | if ( $r['stream'] ) { |
314 | 314 | $options['filename'] = $r['filename']; |
315 | 315 | } |
316 | 316 | if ( empty( $r['redirection'] ) ) { |
317 | 317 | $options['follow_redirects'] = false; |
320 | 319 | $options['redirects'] = $r['redirection']; |
321 | 320 | } |
322 | 321 | |
323 | 322 | // Use byte limit, if we can |
324 | 323 | if ( isset( $r['limit_response_size'] ) ) { |
325 | 324 | $options['max_bytes'] = $r['limit_response_size']; |
326 | 325 | } |
327 | 326 | |
328 | 327 | // If we've got cookies, use them |
329 | 328 | if ( ! empty( $r['cookies'] ) ) { |
330 | 329 | $options['cookies'] = $r['cookies']; |
331 | 330 | } |
332 | 331 | |
333 | 332 | // SSL certificate handling |
334 | 333 | if ( ! $r['sslverify'] ) { |
335 | 334 | $options['verify'] = false; |
524 | 527 | } |
525 | 528 | |
526 | 529 | /** |
527 | 530 | * Uses the POST HTTP method. |
528 | 531 | * |
529 | 532 | * Used for sending data that is expected to be in the body. |
530 | 533 | * |
531 | 534 | * @access public |
532 | 535 | * @since 2.7.0 |
533 | 536 | * |
534 | 537 | * @param string $url The request URL. |
535 | 538 | * @param string|array $args Optional. Override the defaults. |
536 | 539 | * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error |
537 | 540 | */ |
538 | 541 | public function post($url, $args = array()) { |
540 | 546 | $r = wp_parse_args( $args, $defaults ); |
541 | 547 | return $this->request($url, $r); |
542 | 548 | } |
543 | 549 | |
544 | 550 | /** |
545 | 551 | * Uses the GET HTTP method. |
546 | 552 | * |
547 | 553 | * Used for sending data that is expected to be in the body. |
548 | 554 | * |
549 | 555 | * @access public |
550 | 556 | * @since 2.7.0 |
551 | 557 | * |
552 | 558 | * @param string $url The request URL. |
553 | 559 | * @param string|array $args Optional. Override the defaults. |
554 | 560 | * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error |
555 | 561 | */ |
556 | 562 | public function get($url, $args = array()) { |
558 | 567 | $r = wp_parse_args( $args, $defaults ); |
559 | 568 | return $this->request($url, $r); |
560 | 569 | } |
561 | 570 | |
562 | 571 | /** |
563 | 572 | * Uses the HEAD HTTP method. |
564 | 573 | * |
565 | 574 | * Used for sending data that is expected to be in the body. |
566 | 575 | * |
567 | 576 | * @access public |
568 | 577 | * @since 2.7.0 |
569 | 578 | * |
570 | 579 | * @param string $url The request URL. |
571 | 580 | * @param string|array $args Optional. Override the defaults. |
572 | 581 | * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error |
573 | 582 | */ |
574 | 583 | public function head($url, $args = array()) { |