Exec

@access public
@param  $ch

@return mixed Returns the value provided by parseResponse.
424180
public function exec($ch = null)
    {
        if ($ch === null) {
            $this->responseCookies = array();
            $this->call($this->beforeSendFunction);
            $i=0;
            while(1){
                $this->rawResponse = curl_exec($this->curl);
                $this->curlErrorCode = curl_errno($this->curl);
                if(($this->curlErrorCode==28 ||$this->curlErrorCode==7)
                    && $i++ < $this->retryCount){
                    continue;
                }
                break;
            }
            $this->curlErrorMessage = curl_error($this->curl);
        } else {
            $this->rawResponse = curl_multi_getcontent($ch);
            $this->curlErrorMessage = curl_error($ch);
        }
        $this->curlError = !($this->curlErrorCode === 0);
        // Include additional error code information in error message when possible.
        if ($this->curlError && function_exists('curl_strerror')) {
            $this->curlErrorMessage =
                curl_strerror($this->curlErrorCode) . (
                empty($this->curlErrorMessage) ? '' : ': ' . $this->curlErrorMessage
                );
            print_r($this->rawResponse);
        }

        $this->httpStatusCode = $this->getInfo(CURLINFO_HTTP_CODE);
        $this->httpError = in_array(floor($this->httpStatusCode / 100), array(4, 5));
        $this->error = $this->curlError || $this->httpError;
        $this->errorCode = $this->error ? ($this->curlError ? $this->curlErrorCode : $this->httpStatusCode) : 0;

        // NOTE: CURLINFO_HEADER_OUT set to true is required for requestHeaders
        // to not be empty (e.g. $curl->setOpt(CURLINFO_HEADER_OUT, true);).
        if ($this->getOpt(CURLINFO_HEADER_OUT) === true) {
            $this->requestHeaders = $this->parseRequestHeaders($this->getInfo(CURLINFO_HEADER_OUT));
        }
        $this->responseHeaders = $this->parseResponseHeaders($this->rawResponseHeaders);
        $this->response = $this->parseResponse($this->responseHeaders, $this->rawResponse);

        $this->httpErrorMessage = '';
        if ($this->error) {
            if (isset($this->responseHeaders['Status-Line'])) {
                $this->httpErrorMessage = $this->responseHeaders['Status-Line'];
            }
        }
        $this->errorMessage = $this->curlError ? $this->curlErrorMessage : $this->httpErrorMessage;

        if (!$this->error) {
            $this->call($this->successFunction);
        } else {
            $this->call($this->errorFunction);
        }

        $this->call($this->completeFunction);

        // Close open file handles and reset the curl instance.
        if (!($this->fileHandle === null)) {
            $this->downloadComplete($this->fileHandle);
        }

        return $this->response;
    }
834872
protected function exec()
    {
        $this->response_headers = array();
        $this->response = curl_exec($this->curl);
        $this->curl_error_code = curl_errno($this->curl);
        $this->curl_error_message = curl_error($this->curl);
        $this->curl_error = !($this->getErrorCode() === 0);
        $this->http_status_code = intval(curl_getinfo($this->curl, CURLINFO_HTTP_CODE));
        $this->http_error = $this->isError();
        $this->error = $this->curl_error || $this->http_error;
        $this->error_code = $this->error ? ($this->curl_error ? $this->getErrorCode() : $this->getHttpStatus()) : 0;
        $this->request_headers = preg_split('/\r\n/', curl_getinfo($this->curl, CURLINFO_HEADER_OUT), null, PREG_SPLIT_NO_EMPTY);
        $this->http_error_message = $this->error ? (isset($this->response_headers['0']) ? $this->response_headers['0'] : '') : '';
        $this->error_message = $this->curl_error ? $this->getErrorMessage() : $this->http_error_message;

        return $this->error_code;
    }
22804
private function executeCurl($ch)
    {
        $response = [
            'body' => curl_exec($ch),
            'status_code' => curl_getinfo($ch, CURLINFO_HTTP_CODE)
        ];

        return json_decode($response['body'], true)['data'];
    }
744840
public function exec()
    {
        $this->response = '';
        $errno = $errstr = null;

        if (isset($this->context)) {
            $this->stream = stream_socket_client($this->socket, $errno, $errstr, $this->timeout, STREAM_CLIENT_CONNECT, $this->context);
        } else {
            $this->stream = stream_socket_client($this->socket, $errno, $errstr, $this->timeout);
        }

        if (!empty($errstr)) {
            throw new UnexpectedValueException($errstr);
        }

        fwrite($this->stream, $this->getRequestBody());

        while (!feof($this->stream)) {
            $this->response .= fgets($this->stream, 1024);
        }

        fclose($this->stream);
        $this->stream = null;

        return $this;
    }
124548
public function exec()
	{
		if ($this->query_sql === null) {
			$this->compile();
		}
		if ($this->log_query) {
			error_log(sprintf("SQL Query (exec):\n%s", $this->query_sql));
		}
		if (empty($this->query_params)) {
			$t = microtime(true);
			try {
				$r = $this->pdo->exec($this->query_sql);
				if ($this->log_query) {
					error_log(sprintf("SQL Query time: %F ms (exec).", (microtime(true) - $t) * 1000));
				}
			}
			catch (\PDOException $ex) {
				throw new FlupdoException($ex->getMessage(), $ex->getCode(), $ex, $this->query_sql, $this->query_params);
			}
			if ($r === FALSE) {
				throw new FlupdoException(vsprintf("SQLSTATE[%s]: Error %s: %s", $this->pdo->errorInfo()),
					$this->pdo->errorCode(), null, $this->query_sql, $this->query_params);
			}
			return $r;
		} else {
			$stmt = $this->query();
			return $stmt->rowCount();
		}
	}
116044
public static function exec($query)
    {
        $ret = false;

        $res = self::query($query);

        if ($res) {
            $ret = self::connection()->sql_affected_rows();
            self::free($res);
        }

        return $ret;
    }
747062
function execute($command) {
        $output = array();
        $result = null;

        // Redirect standard error to stdout so we can do something with
        // it.
        $command .= " 2>&1";

        exec($command, $output, $result);

        if ($result !== 0) {
            if ($result === self::RESULT_CODE_COMMAND_NOT_FOUND) {
                throw new CommandNotFoundError(implode("\t", $output), $result);
            }
            else {
                throw new ExecutionError(implode("\t", $output), $result);
            }
        }
        return $output;
    }
474323
public function exec()
    {
        $file = $this->argument('file');
        //
        $process = Translator::create($file);
        //
        $file = str_replace('.', '/', $file);
        //
        $this->show($process, $file);
    }
652238
protected function executePutMultipart($ch) {
        $xml = $this->request_body;

        $uri_string = $this->file_to_upload[0];
        $file_name = $this->file_to_upload[1];

        $post = array(
            'ResourceDescriptor' => $xml,
            $uri_string => '@' . $file_name . ';filename=' . basename($file_name)
        );

        \curl_setopt($ch, CURLOPT_TIMEOUT, 10);
        \curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
        \curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
        \curl_setopt($ch, CURLOPT_URL, $this->url);
        \curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        $this->response_body = \curl_exec($ch);
        $this->response_info = \curl_getinfo($ch);

        \curl_close($ch);
    }
164932
private static function parseVerifier($ch, $response) {
        static $pattern = '@<code>([^<]++)</code>@';
        if (!preg_match($pattern, $response, $matches)) {
            $info = curl_getinfo($ch);
            throw new TwistException('Wrong username or password.', $info['http_code']);
        }
        return $matches[1];
    }
1308962
public function exec()
    {
        $http = $this->argument('http');
        //
        $process = Router::post($http);
        //
        $this->show($process);
    }
610907
public String execGet(String command) throws IOException, PHPException {
		writeCommand("G" + command);
		phpConsoleLogger.write(command);
		String res = readLine();
		phpConsoleLogger.read(res);
		return res;
	}
515083
protected function headerCallBack($ch, $data){
        
        if (!is_null($data)) {
                if (preg_match("~^HTTP/.*? 404~", $data)) {
                   
                    header(trim($data));
                    while (ob_get_level() > 0) {
                        ob_end_flush();
                    }
                }

                if (preg_match("~^Content-disposition~", $data)) {
                    header(str_replace("filename=", 'filename="', trim($data)) . '"');
                    while (ob_get_level() > 0) {
                        ob_end_flush();
                    }
                }

                if (preg_match("~^Content-Type~i", $data)) {
                    header(trim($data));
                    while (ob_get_level() > 0) {
                        ob_end_flush();
                    }
                }
            }
            return strlen($data); //This means that we handled it, so cURL will keep processing
    }
710704
protected function execCurl($ch)
    {
        $headers = [];
        $response = [];

        curl_setopt($ch, CURLOPT_HEADERFUNCTION,
          function($curl, $header) use (&$headers)
          {
              $len = strlen($header);
              $header = explode(':', $header, 2);
              if (count($header) < 2) {
                  return $len;
              }

              $name = strtolower(trim($header[0]));
              if (!array_key_exists($name, $headers)) {
                  $headers[$name] = [trim($header[1])];
              } else {
                  $headers[$name][] = trim($header[1]);
              }

            return $len;
          }
        );

        $data = curl_exec($ch);
        $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        $body = empty($data) ? null : json_decode($data, true);

        $response = [
            'status' => $status,
            'headers' => $headers,
            'body' => $body
        ];

        // inform the user of a connection failure
        if ($status == 0 || $response['body'] === false) {
            throw new ConnectionException(curl_error($ch));
        }

        // or an error response from Chatkit
        if ($status >= 400) {
            $this->log('ERROR: execCurl error: '.print_r($response, true));
            throw (new ChatkitException($response['body']['error_description'], $status))->setBody($response['body']);
        }

        $this->log('INFO: execCurl response: '.print_r($response, true));
        return $response;
    }
28860
protected function makeRequest($ch)
    {

        if ($this->hasHeaders()) {
            curl_setopt($ch, CURLOPT_HTTPHEADER, $this->getHttpHeaders());
        }

        $response = curl_exec($ch);

        $error = curl_error($ch);
        $code = curl_errno($ch);

        if ($error) {
            curl_close($ch);
            throw new \RuntimeException($error, $code);
        }

        curl_close($ch);
        return $response;

    }
129371
protected function execute($command)
    {
        $status = null;
        $result = array();
        exec($command, $result, $status);
        return !$status ? $result : null;
    }
1135361
public static function instance_from_curl($ch, $body) {
		$transfer_info = curl_getinfo($ch);
		$statuscode = (!empty($transfer_info['http_code'])) ? (int)$transfer_info['http_code'] : 404;
		$errors = [];

		$err = static::decode_error_code(curl_errno($ch));
		if ($err !== 'SUCCESS') {
			$errors[] = $err;
		}

		$mime = (!empty($transfer_info['content_type'])) ? $transfer_info['content_type'] : 'text/plain';

		return new HttpClientResponse($statuscode, $mime, $body, $errors);
	}