예제 #1
0
 /**
  * Apply POST fields and files to a request to attempt to give an accurate
  * representation.
  *
  * @param puzzle_message_RequestInterface $request Request to update
  * @param array            $body    Body to apply
  */
 protected function addPostData(puzzle_message_RequestInterface $request, array $body)
 {
     static $fields = array('string' => true, 'array' => true, 'NULL' => true, 'boolean' => true, 'double' => true, 'integer' => true);
     $post = new puzzle_post_PostBody();
     foreach ($body as $key => $value) {
         if (isset($fields[gettype($value)])) {
             $post->setField($key, $value);
         } elseif ($value instanceof puzzle_post_PostFileInterface) {
             $post->addFile($value);
         } else {
             $post->addFile(new puzzle_post_PostFile($key, $value));
         }
     }
     if ($request->getHeader('Content-Type') == 'multipart/form-data') {
         $post->forceMultipartUpload(true);
     }
     $request->setBody($post);
 }
예제 #2
0
 private function add_decode_content(puzzle_message_RequestInterface $request, puzzle_adapter_curl_RequestMediator $mediator, $value)
 {
     if (!$request->hasHeader('Accept-Encoding')) {
         $this->_closure_handleOptions[CURLOPT_ENCODING] = '';
         // Don't let curl send the header over the wire
         $this->_closure_handleOptions[CURLOPT_HTTPHEADER][] = 'Accept-Encoding:';
     } else {
         $this->_closure_handleOptions[CURLOPT_ENCODING] = $request->getHeader('Accept-Encoding');
     }
 }