Prepares the request to the API.
352166
protected function build()
    {
        $this->rawXml = $this->buildXML();

        $this->client->setDefaultOption('headers', array(
            'Content-Type' => 'application/x-www-form-urlencoded'
        ));

        $this->request = $this->client->post(null, null, array(
            "xml" => ($this->rawXml->saveXML())
        ));
    }
658866
protected function prepareForResponse()
    {
        if ($this->preparedForResponse) {
            return;
        }

        $this->loadView();
        $this->loadThemer();
        $this->loadThemerDefaultFiles($this->config);
        $this->loadGlobalViewVariables($this->config);

        if (method_exists($this, 'prepareExtraForResponse')) {
            $this->prepareExtraForResponse();
        }

        $this->preparedForResponse = true;
    }
238622
protected function prepare()
    {
        if (!is_array($this->data) || count($this->data) == 0) {
            $this->setData($this->read());
        }
    }
820297
def prepare(self):
        
        super(RequestHandler, self).prepare()
        if self.request.headers.get('content-type', '').startswith(self.JSON):
            self.request.body = escape.json_decode(self.request.body)
1088932
def prepare_request(self, method, url, body=''):
        
        headers = {
            'Content-type': 'application/json',
        }
        # Note: we don't pass body to sign() since it's only for bodies that
        # are form-urlencoded. Similarly, we don't care about the body that
        # sign() returns.
        uri, signed_headers, signed_body = self.oauth_client.sign(
            url, http_method=method, headers=headers)
        if body:
            if method == 'GET':
                body = urllib.urlencode(body)
            else:
                body = json.dumps(body)
        headers.update(signed_headers)
        return {"headers": headers, "data": body}
746833
def _prepare_request(reddit_session, url, params, data, auth, files,
                     method=None):
    """"""
    # Requests using OAuth for authorization must switch to using the oauth
    # domain.
    if getattr(reddit_session, '_use_oauth', False):
        bearer = 'bearer {0}'.format(reddit_session.access_token)
        headers = {'Authorization': bearer}
        config = reddit_session.config
        for prefix in (config.api_url, config.permalink_url):
            if url.startswith(prefix):
                if config.log_requests >= 1:
                    msg = 'substituting {0} for {1} in url\n'.format(
                        config.oauth_url, prefix)
                    sys.stderr.write(msg)
                url = config.oauth_url + url[len(prefix):]
                break
    else:
        headers = {}
    headers.update(reddit_session.http.headers)

    if method:
        pass
    elif data or files:
        method = 'POST'
    else:
        method = 'GET'

    # Log the request if logging is enabled
    if reddit_session.config.log_requests >= 1:
        sys.stderr.write('{0}: {1}\n'.format(method, url))
    if reddit_session.config.log_requests >= 2:
        if params:
            sys.stderr.write('params: {0}\n'.format(params))
        if data:
            sys.stderr.write('data: {0}\n'.format(data))
        if auth:
            sys.stderr.write('auth: {0}\n'.format(auth))
    # Prepare request
    request = Request(method=method, url=url, headers=headers, params=params,
                      auth=auth, cookies=reddit_session.http.cookies)
    if method == 'GET':
        return request
    # Most POST requests require adding `api_type` and `uh` to the data.
    if data is True:
        data = {}

    if isinstance(data, dict):
        if not auth:
            data.setdefault('api_type', 'json')
            if reddit_session.modhash:
                data.setdefault('uh', reddit_session.modhash)
    else:
        request.headers.setdefault('Content-Type', 'application/json')

    request.data = data
    request.files = files
    return request
418756
def _prepare_request_json(self, kwargs):
        """"""

        # Check for python keywords in dict
        kwargs = self._check_for_python_keywords(kwargs)

        # Check for the key 'check' in kwargs
        if 'check' in kwargs:
            od = OrderedDict()
            od['check'] = kwargs['check']
            kwargs.pop('check')
            od.update(kwargs)
            return od
        return kwargs
1256100
def _prepare_fetch(self, request: Request, response: Response):
        '''
        '''
        self._request = request
        self._response = response

        yield from self._init_stream()

        connection_closed = self._control_connection.closed()

        if connection_closed:
            self._login_table.pop(self._control_connection, None)
            yield from self._control_stream.reconnect()

        request.address = self._control_connection.address

        connection_reused = not connection_closed
        self.event_dispatcher.notify(self.Event.begin_control, request, connection_reused=connection_reused)

        if connection_closed:
            yield from self._commander.read_welcome_message()

        yield from self._log_in()

        self._response.request = request
324398
def prepare(self):
        
        requested_access = self.endpoint_access(self.request.method)
        use_oauth = getattr(options, 'use_oauth', None)
        if use_oauth and requested_access is not self.UNAUTHENTICATED_ACCESS:
            token = self.request.headers.get('Authorization', '').split(' ')[-1]
            if token:
                has_access = yield self.verify_token(token, requested_access)
                if not has_access:
                    msg = "'{}' access not granted.".format(requested_access)
                    raise HTTPError(403, msg)
            else:
                msg = 'OAuth token not provided'
                raise HTTPError(401, msg)
1139751
public function prep_request() {
		$curl_handle = curl_init ();
		// Set default options.
		curl_setopt ( $curl_handle, CURLOPT_URL, $this->request_url );
		curl_setopt ( $curl_handle, CURLOPT_FILETIME, true );
		curl_setopt ( $curl_handle, CURLOPT_FRESH_CONNECT, false );
		curl_setopt ( $curl_handle, CURLOPT_SSL_VERIFYPEER, false );
		curl_setopt ( $curl_handle, CURLOPT_SSL_VERIFYHOST, true );
		curl_setopt ( $curl_handle, CURLOPT_CLOSEPOLICY, CURLCLOSEPOLICY_LEAST_RECENTLY_USED );
		curl_setopt ( $curl_handle, CURLOPT_MAXREDIRS, 5 );
		curl_setopt ( $curl_handle, CURLOPT_HEADER, true );
		curl_setopt ( $curl_handle, CURLOPT_RETURNTRANSFER, true );
		curl_setopt ( $curl_handle, CURLOPT_TIMEOUT, 5184000 );
		curl_setopt ( $curl_handle, CURLOPT_CONNECTTIMEOUT, 120 );
		curl_setopt ( $curl_handle, CURLOPT_NOSIGNAL, true );
		curl_setopt ( $curl_handle, CURLOPT_REFERER, $this->request_url );
		curl_setopt ( $curl_handle, CURLOPT_USERAGENT, $this->useragent );
		curl_setopt ( $curl_handle, CURLOPT_READFUNCTION, array (
				$this,
				'streaming_read_callback' ) );
		if ($this->debug_mode) {
			curl_setopt ( $curl_handle, CURLOPT_VERBOSE, true );
		}
		//if (! ini_get ( 'safe_mode' )) {
		//modify by zhengkan
		//curl_setopt($curl_handle, CURLOPT_FOLLOWLOCATION, true);
		//}
		// Enable a proxy connection if requested.
		if ($this->proxy) {
			curl_setopt ( $curl_handle, CURLOPT_HTTPPROXYTUNNEL, true );
			$host = $this->proxy ['host'];
			$host .= ($this->proxy ['port']) ? ':' . $this->proxy ['port'] : '';
			curl_setopt ( $curl_handle, CURLOPT_PROXY, $host );
			if (isset ( $this->proxy ['user'] ) && isset ( $this->proxy ['pass'] )) {
				curl_setopt ( $curl_handle, CURLOPT_PROXYUSERPWD, $this->proxy ['user'] . ':' . $this->proxy ['pass'] );
			}
		}
		// Set credentials for HTTP Basic/Digest Authentication.
		if ($this->username && $this->password) {
			curl_setopt ( $curl_handle, CURLOPT_HTTPAUTH, CURLAUTH_ANY );
			curl_setopt ( $curl_handle, CURLOPT_USERPWD, $this->username . ':' . $this->password );
		}
		// Handle the encoding if we can.
		if (extension_loaded ( 'zlib' )) {
			curl_setopt ( $curl_handle, CURLOPT_ENCODING, '' );
		}
		// Process custom headers
		if (isset ( $this->request_headers ) && count ( $this->request_headers )) {
			$temp_headers = array ();
			foreach ( $this->request_headers as $k => $v ) {
				$temp_headers [] = $k . ': ' . $v;
			}
			curl_setopt ( $curl_handle, CURLOPT_HTTPHEADER, $temp_headers );
		}
		switch ($this->method) {
			case self::HTTP_PUT :
				curl_setopt ( $curl_handle, CURLOPT_CUSTOMREQUEST, 'PUT' );
				if (isset ( $this->read_stream )) {
					if (! isset ( $this->read_stream_size ) || $this->read_stream_size < 0) {
						throw new BCS_RequestCore_Exception ( 'The stream size for the streaming upload cannot be determined.' );
					}
					curl_setopt ( $curl_handle, CURLOPT_INFILESIZE, $this->read_stream_size );
					curl_setopt ( $curl_handle, CURLOPT_UPLOAD, true );
				} else {
					curl_setopt ( $curl_handle, CURLOPT_POSTFIELDS, $this->request_body );
				}
				break;
			case self::HTTP_POST :
				curl_setopt ( $curl_handle, CURLOPT_POST, true );
				curl_setopt ( $curl_handle, CURLOPT_POSTFIELDS, $this->request_body );
				break;
			case self::HTTP_HEAD :
				curl_setopt ( $curl_handle, CURLOPT_CUSTOMREQUEST, self::HTTP_HEAD );
				curl_setopt ( $curl_handle, CURLOPT_NOBODY, 1 );
				break;
			default : // Assumed GET
				curl_setopt ( $curl_handle, CURLOPT_CUSTOMREQUEST, $this->method );
				if (isset ( $this->write_stream )) {
					curl_setopt ( $curl_handle, CURLOPT_WRITEFUNCTION, array (
							$this,
							'streaming_write_callback' ) );
					curl_setopt ( $curl_handle, CURLOPT_HEADER, false );
				} else {
					curl_setopt ( $curl_handle, CURLOPT_POSTFIELDS, $this->request_body );
				}
				break;
		}
		// Merge in the CURLOPTs
		if (isset ( $this->curlopts ) && sizeof ( $this->curlopts ) > 0) {
			foreach ( $this->curlopts as $k => $v ) {
				curl_setopt ( $curl_handle, $k, $v );
			}
		}
		return $curl_handle;
	}
20168
def prepare_params(request):
    """"""
    return request.replace(
        params={key: dump_param(val) for key, val in request.params.items()
                if val is not None})
930431
protected function prepareRequest()
    {
        $request = Request::capture();
        $request->setSession($this->app['session']);
        //$request->enableHttpMethodParameterOverride();

        $this->app->singleton('Nano7\Http\Request');
        $this->app->alias('request', 'Nano7\Http\Request');
        $this->app->instance('request', $request);

        return $request;
    }
149809
public function prepare()
    {
        $files = $this->getFilesStack();
        if (!empty($files)) {
            foreach ($files as $_file) {
                $this->addContent(
                    file_get_contents($_file->getRealPath()),
                    $_file->getPathname()
                );
            }
        }
    }
743763
def prepare(self):
        
        # Maybe the Brok is a old daemon one or was already prepared
        # if so, the data is already ok
        if hasattr(self, 'prepared') and not self.prepared:
            self.data = unserialize(self.data)
            if self.instance_id:
                self.data['instance_id'] = self.instance_id
        self.prepared = True
1057253
protected function prepareCurl()
    {
        $this->curl = curl_init();
        $this->complete = Complete::factory(function() {
            if ($this->curl) {
                curl_close($this->curl);
            }
            $this->curl     = null;
            $this->complete = null;
        });

        foreach(self::$curlOptions as $option => $value) {
            curl_setopt($this->curl, $option, $value);
        }
        if ($this->method === HttpMethods::POST) {
            curl_setopt($this->curl, CURLOPT_POST, true);
        }
        if (!empty($this->auth)) {
            curl_setopt($this->curl, CURLOPT_USERPWD, sprintf(
                "%s:%s",
                $this->auth["user"],
                $this->auth["pass"]
            ));
        }
    }
914069
protected void prepareRequest() {
		LOG.debug("Preparing for request by adding headers and environment to top wcomponent");

		// Configure the UIContext to handle this request.
		UIContext uiContext = getUIContext();

		// Add WEnvironment if not already done.
		// If the component is new, then it will not have a WEnvironment yet.
		Environment env;

		if (uiContext.isDummyEnvironment()) {
			env = createEnvironment();
			uiContext.setEnvironment(env);
		} else {
			env = uiContext.getEnvironment();
		}

		// Update the environment for the current phase of the request
		// processing.
		updateEnvironment(env);

		// Prepare an implementation of a wcomponent Request suitable to the
		// type of
		// container we are running in.
		if (getRequest() == null) {
			setRequest(createRequest());
		}

		// Update the wcomponent Request for the current phase of the request
		// processing.
		updateRequest(getRequest());
	}
1350061
public function request()
    {
        $data = $this->prepareData();

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $this->apiHost . '/api');
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        $result = curl_exec($ch);
        $this->checkResult($result);

        return $result;
    }