bhubbard
4/17/2017 - 8:52 PM

gistfile1.txt

<?php

  // TODO: More Methods Here: https://msdn.microsoft.com/en-us/library/aa142917(v=exchg.65).aspx

	public function patch($url, $args = array()) {
		$defaults = array('method' => 'PATCH');
		$r = wp_parse_args( $args, $defaults );
		return $this->request($url, $r);
	}
	
	public function copy($url, $args = array()) {
		$defaults = array('method' => 'COPY');
		$r = wp_parse_args( $args, $defaults );
		return $this->request($url, $r);
	}

	public function link($url, $args = array()) {
		$defaults = array('method' => 'LINK');
		$r = wp_parse_args( $args, $defaults );
		return $this->request($url, $r);
	}
	
	public function unlink($url, $args = array()) {
		$defaults = array('method' => 'UNLINK');
		$r = wp_parse_args( $args, $defaults );
		return $this->request($url, $r);
	}
	
	public function purge($url, $args = array()) {
		$defaults = array('method' => 'PURGE');
		$r = wp_parse_args( $args, $defaults );
		return $this->request($url, $r);
	}
	
	public function lock($url, $args = array()) {
		$defaults = array('method' => 'LOCK');
		$r = wp_parse_args( $args, $defaults );
		return $this->request($url, $r);
	}
	
	public function unlock($url, $args = array()) {
		$defaults = array('method' => 'UNLOCK');
		$r = wp_parse_args( $args, $defaults );
		return $this->request($url, $r);
	}
	
	public function propfind($url, $args = array()) {
		$defaults = array('method' => 'PROPFIND');
		$r = wp_parse_args( $args, $defaults );
		return $this->request($url, $r);
	}
	
	public function view($url, $args = array()) {
		$defaults = array('method' => 'VIEW');
		$r = wp_parse_args( $args, $defaults );
		return $this->request($url, $r);
	}
	
	public function connect($url, $args = array()) {
		$defaults = array('method' => 'CONNECT');
		$r = wp_parse_args( $args, $defaults );
		return $this->request($url, $r);
	}
	
	
	
	
function wp_safe_remote_options( $url, $args = array() ) {
	$args['reject_unsafe_urls'] = true;
	$http = _wp_http_get_object();
	return $http->options( $url, $args );
}

function wp_remote_options($url, $args = array()) {
	$http = _wp_http_get_object();
	return $http->options( $url, $args );
}


function test_get_options() {
  $url = 'https://public-api.wordpress.com/rest/v1.2/';
  
  $response = wp_remote_options( $url );
  $headers = wp_remote_retrieve_headers( $response );
  
  $this->assertInternalType( 'array', $response );
  
  // Should return an Allow Header or Method.
  $this->assertEquals( 'GET, POST', $headers['Access-Control-Allow-Methods'] );
}