Exemplo n.º 1
0
 /**
  * @param $body HTTP POST body data
  * @param $type content type, e.g. 'text/xml; charset=UTF-8'. Replaces any value for the
  * 'Content-Type' header that may have been set by another method.
  */
 public function setBody($body, $type)
 {
     PhpUtil::assertString($body, 'body');
     PhpUtil::assertString($type, 'type');
     $this->body = $body;
     $this->headers['Content-Type'] = $type;
 }
Exemplo n.º 2
0
 /**
  * @param $params query params - array keys are the names, array values the values.
  * Values may be arrays. http://php.net/http_build_query is used to build the query.
  * TODO: http_build_query() may not always be the best way to deal with multi-valued
  * parameters. Maybe we should implement it here.
  */
 public function setParams($params)
 {
     if ($this->url === null) {
         throw new \InvalidArgumentException('set url first');
     }
     PhpUtil::assertArray($params, 'params');
     $this->url .= '?' . http_build_query($params);
 }
Exemplo n.º 3
0
 /**
  * See CURLOPT_POSTFIELDS on http://php.net/curl_setopt . The 'Content-Type' header should
  * not be set by any other method, cURL will set it to 'multipart/form-data'.
  * @param $fields array with the field name as key and field data as value. To post a file,
  * prepend a filename with @ and use the full path as the value. 
  */
 public function setFields($fields)
 {
     PhpUtil::assertArray($fields, 'fields');
     $this->fields = $fields;
 }
Exemplo n.º 4
0
 /**
  * A value in the given array replaces the value for the same key that may have been
  * set by other methods. If another method set a value for a header key that does not
  * occur in the given array, that value is not removed or replaced.
  * @param $headers http headers - array keys are the names, array values the values. 
  */
 public function setHeaders($headers)
 {
     PhpUtil::assertArray($headers, 'headers');
     $this->headers = array_merge($this->headers, $headers);
 }
Exemplo n.º 5
0
 /**
  * @param $file (string) file path
  */
 public function __construct($file)
 {
     PhpUtil::assertString($file, 'file');
     $this->file = $file;
 }
Exemplo n.º 6
0
 /**
  * @param $params query params - array keys are the names, array values the values.
  * Values may be arrays. http://php.net/http_build_query is used to build the query.
  * TODO: http_build_query() may not always be the best way to deal with multi-valued
  * parameters. Maybe we should implement it here.
  */
 public function setParams($params)
 {
     PhpUtil::assertArray($params, 'params');
     $this->body = http_build_query($params);
 }