本文整理汇总了PHP中Apache_Solr_Response::getHttpStatusMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP Apache_Solr_Response::getHttpStatusMessage方法的具体用法?PHP Apache_Solr_Response::getHttpStatusMessage怎么用?PHP Apache_Solr_Response::getHttpStatusMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Apache_Solr_Response
的用法示例。
在下文中一共展示了Apache_Solr_Response::getHttpStatusMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _sendRawPost
/**
* Central method for making a post operation against this Solr Server
*
* @see Drupal_Apache_Solr_Service::_sendRawGet()
*/
protected function _sendRawPost($url, $rawPost, $timeout = FALSE, $contentType = 'text/xml; charset=UTF-8')
{
$this->add_request_id($url);
list($cookie, $nonce) = acquia_search_auth_cookie($url, $rawPost);
$request_headers = array('Content-Type' => $contentType, 'Cookie' => $cookie);
list($data, $headers) = $this->_makeHttpRequest($url, 'POST', $request_headers, $rawPost, $timeout);
$response = new Apache_Solr_Response($data, $headers, $this->_createDocuments, $this->_collapseSingleValueArrays);
if ($response->getHttpStatus() != 200) {
throw new Exception('"' . $response->getHttpStatus() . '" Status: ' . $response->getHttpStatusMessage() . "\n<br />request ID: {$id} <br />" . $url, $response->getHttpStatus());
}
return $response;
}
示例2: _sendRawPost
/**
* Central method for making a post operation against this Solr Server
*
* @see Drupal_Apache_Solr_Service::_sendRawGet()
*/
protected function _sendRawPost($url, $rawPost, $timeout = FALSE, $contentType = 'text/xml; charset=UTF-8')
{
$id = $this->add_request_id($url);
list($cookie, $nonce) = acquia_search_auth_cookie($url, $rawPost);
$request_headers = array('Content-Type' => $contentType, 'Cookie' => $cookie, 'User-Agent' => 'acquia_search/' . ACQUIA_SEARCH_VERSION);
list($data, $headers) = $this->_makeHttpRequest($url, 'POST', $request_headers, $rawPost, $timeout);
$response = new Apache_Solr_Response($data, $headers, $this->_createDocuments, $this->_collapseSingleValueArrays);
$code = (int) $response->getHttpStatus();
if ($code != 200) {
$message = $response->getHttpStatusMessage() . "\n request ID: {$id} \n";
if ($code >= 400 && $code != 403 && $code != 404) {
// Add details, like Solr's exception message.
$message .= $response->getRawResponse();
}
throw new Exception('"' . $code . '" Status: ' . $message);
}
return $response;
}
示例3: _sendRawPost
/**
* Central method for making a post operation against this Solr Server
*
* @see Drupal_Apache_Solr_Service::_sendRawGet()
*/
protected function _sendRawPost($url, $rawPost, $timeout = FALSE, $contentType = 'text/xml; charset=UTF-8')
{
if (variable_get('apachesolr_read_only', 0)) {
throw new Exception('Operating in read-only mode; updates are disabled.');
}
$id = $this->add_request_id($url);
list($cookie, $nonce) = acquia_search_auth_cookie($url, $rawPost);
if (empty($cookie)) {
throw new Exception('Invalid authentication string - subscription keys expired or missing.');
}
$request_headers = array('Content-Type' => $contentType, 'Cookie' => $cookie, 'User-Agent' => 'acquia_search/' . ACQUIA_SEARCH_VERSION);
list($data, $headers) = $this->_makeHttpRequest($url, 'POST', $request_headers, $rawPost, $timeout);
$response = new Apache_Solr_Response($data, $headers, $this->_createDocuments, $this->_collapseSingleValueArrays);
$code = (int) $response->getHttpStatus();
if ($code != 200) {
$message = $response->getHttpStatusMessage() . "\n request ID: {$id} \n";
if ($code >= 400 && $code != 403 && $code != 404) {
// Add details, like Solr's exception message.
$message .= $response->getRawResponse();
}
throw new Exception('"' . $code . '" Status: ' . $message);
}
return $response;
}
示例4: __construct
/**
* HttpTransportException Constructor
*
* @param Apache_Solr_Response $response
*/
public function __construct(Apache_Solr_Response $response)
{
parent::__construct("'{$response->getHttpStatus()}' Status: {$response->getHttpStatusMessage()}", $response->getHttpStatus());
$this->_response = $response;
}
示例5: _sendRawPost
/**
* Central method for making a post operation against this Solr Server
*
* @see Apache_Solr_Service::_sendRawGet()
*/
protected function _sendRawPost($url, $rawPost, $timeout = FALSE, $contentType = 'text/xml; charset=UTF-8')
{
$request_headers = array('Content-Type' => $contentType);
list($data, $headers) = $this->_makeHttpRequest($url, 'POST', $request_headers, $rawPost, $timeout);
$response = new Apache_Solr_Response($data, $headers, $this->_createDocuments, $this->_collapseSingleValueArrays);
$code = (int) $response->getHttpStatus();
if ($code != 200) {
$message = $response->getHttpStatusMessage();
if ($code >= 400 && $code != 403 && $code != 404) {
// Add details, like Solr's exception message.
$message .= $response->getRawResponse();
}
throw new Exception('"' . $code . '" Status: ' . $message);
}
return $response;
}
示例6: _sendRawPost
/**
* Central method for making a post operation against this Solr Server
*
* @see Apache_Solr_Service::_sendRawGet()
*/
protected function _sendRawPost($url, $rawPost, $timeout = FALSE, $contentType = 'text/xml; charset=UTF-8')
{
$request_headers = array('Content-Type' => $contentType);
list($data, $headers) = $this->_makeHttpRequest($url, 'POST', $request_headers, $rawPost, $timeout);
$response = new Apache_Solr_Response($data, $headers, $this->_createDocuments, $this->_collapseSingleValueArrays);
if ($response->getHttpStatus() != 200) {
throw new Exception('"' . $response->getHttpStatus() . '" Status: ' . $response->getHttpStatusMessage());
}
return $response;
}
示例7: log
/**
* Logs the item and what document was created from it
*
* @param Tx_Solr_IndexQueue_Item The item that is being indexed.
* @param array An array of Solr documents created from the item's data
* @param Apache_Solr_Response The Solr response for the particular index document
*/
protected function log(Tx_Solr_IndexQueue_Item $item, array $itemDocuments, Apache_Solr_Response $response)
{
if (!$this->loggingEnabled) {
return;
}
$message = 'Index Queue indexing ' . $item->getType() . ':' . $item->getRecordUid() . ' - ';
$severity = 0;
// info
// preparing data
$documents = array();
foreach ($itemDocuments as $document) {
$documents[] = (array) $document;
}
$logData = array('item' => (array) $item, 'documents' => $documents, 'response' => (array) $response);
if ($response->getHttpStatus() == 200) {
$severity = -1;
$message .= 'Success';
} else {
$severity = 3;
$message .= 'Failure';
$logData['status'] = $response->getHttpStatus();
$logData['status message'] = $response->getHttpStatusMessage();
}
\TYPO3\CMS\Core\Utility\GeneralUtility::devLog($message, 'solr', $severity, $logData);
}
示例8: searchByPost
public function searchByPost($query, $offset = 0, $limit = 10, $params = array())
{
if (!is_array($params)) {
$params = array();
}
// construct our full parameters
// sending the version is important in case the format changes
$params['version'] = self::SOLR_VERSION;
// common parameters in this interface
$params['wt'] = self::SOLR_WRITER;
$params['json.nl'] = $this->_namedListTreatment;
$params['q'] = $query;
$params['start'] = $offset;
$params['rows'] = $limit;
//$params['qt'] = 'standard';
// use http_build_query to encode our arguments because its faster
// than urlencoding all the parts ourselves in a loop
$queryString = http_build_query($params, null, $this->_queryStringDelimiter);
// because http_build_query treats arrays differently than we want to, correct the query
// string by changing foo[#]=bar (# being an actual number) parameter strings to just
// multiple foo=bar strings. This regex should always work since '=' will be urlencoded
// anywhere else the regex isn't expecting it
$queryString = preg_replace('/%5B(?:[0-9]|[1-9][0-9]+)%5D=/', '=', $queryString);
$postdata = $queryString;
$opts = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata));
$context = stream_context_create($opts);
//$result = file_get_contents('http://example.com/submit.php', false, $context);
$response = new Apache_Solr_Response(@file_get_contents($this->_searchUrl, false, $context), $http_response_header, $this->_createDocuments, $this->_collapseSingleValueArrays);
if ($response->getHttpStatus() != 200) {
throw new Exception('"' . $response->getHttpStatus() . '" Status: ' . $response->getHttpStatusMessage(), $response->getHttpStatus());
}
return $response;
}
示例9: _sendRawPost
/**
* Central method for making a post operation against this Solr Server
*
* @param string $url
* @param string $rawPost
* @param float $timeout Read timeout in seconds
* @param string $contentType
* @return Apache_Solr_Response
*
* @throws Exception If a non 200 response status is returned
*/
protected function _sendRawPost($url, $rawPost, $timeout = FALSE, $contentType = 'text/xml; charset=UTF-8')
{
stream_context_set_option($this->_postContext, array('http' => array('method' => 'POST', 'header' => "Content-Type: {$contentType}", 'content' => $rawPost, 'timeout' => $this->_defaultTimeout)));
// set the timeout if specified
if ($timeout !== FALSE && $timeout > 0.0) {
// timeouts with file_get_contents seem to need
// to be halved to work as expected
$timeout = (double) $timeout / 2;
stream_context_set_option($this->_postContext, 'http', 'timeout', $timeout);
}
//$http_response_header is set by file_get_contents
$response = new Apache_Solr_Response(@file_get_contents($url, false, $this->_postContext), $http_response_header, $this->_createDocuments, $this->_collapseSingleValueArrays);
if ($response->getHttpStatus() != 200) {
throw new Exception('"' . $response->getHttpStatus() . '" Status: ' . $response->getHttpStatusMessage(), $response->getHttpStatus());
}
return $response;
}
示例10: _sendRawPost
/**
* Central method for making a post operation against this Solr Server
*
* @param string $url
* @param string $rawPost
* @param float $timeout Read timeout in seconds
* @param string $contentType
* @return Apache_Solr_Response
*
* @throws Exception If a non 200 response status is returned
*/
protected function _sendRawPost($url, $rawPost, $timeout = FALSE, $contentType = 'text/xml; charset=UTF-8')
{
//ensure content type is correct
stream_context_set_option($this->_postContext, 'http', 'header', 'Content-Type: ' . $contentType);
//set the read timeout if specified
if ($timeout !== FALSE) {
stream_context_set_option($this->_postContext, 'http', 'timeout', $timeout);
}
//set the content
stream_context_set_option($this->_postContext, 'http', 'content', $rawPost);
//$http_response_header is set by file_get_contents
$response = new Apache_Solr_Response(@file_get_contents($url, false, $this->_postContext), $http_response_header, $this->_createDocuments, $this->_collapseSingleValueArrays);
if ($response->getHttpStatus() != 200) {
throw new Exception('"' . $response->getHttpStatus() . '" Status: ' . $response->getHttpStatusMessage(), $response->getHttpStatus());
}
return $response;
}
示例11: _getResponse
/**
* Read response for prepared curl request
*
* @return Apache_Solr_Response
*
* @throws Exception If a non 200 response status is returned
*/
protected function _getResponse()
{
$response = $this->_curlAdapter->read();
$this->_curlAdapter->close();
list($headers, $body) = explode("\r\n\r\n", $response, 2);
$headers = explode("\r\n", $headers);
$response = new Apache_Solr_Response($body, $headers, $this->_createDocuments, $this->_collapseSingleValueArrays);
$httpStatus = $response->getHttpStatus();
if ($httpStatus != 200) {
throw new Exception('"' . $httpStatus . '" Status: ' . $response->getHttpStatusMessage(), $httpStatus);
}
return $response;
}
示例12: makeServletRequest
/**
* Make a request to a servlet (a path) that's not a standard path.
*
* @param string $servlet
* A path to be added to the base Solr path. e.g. 'extract/tika'
*
* @param array $params
* Any request parameters when constructing the URL.
*
* @param string $method
* 'GET', 'POST', 'PUT', or 'HEAD'.
*
* @param array $request_headers
* Keyed array of header names and values. Should include 'Content-Type'
* for POST or PUT.
*
* @param string $rawPost
* Must be an empty string unless method is POST or PUT.
*
* @param float $timeout
* Read timeout in seconds or FALSE.
*
* @return
* Apache_Solr_Response object
*/
public function makeServletRequest($servlet, $params = array(), $method = 'GET', $request_headers = array(), $rawPost = '', $timeout = FALSE)
{
if ($method == 'GET' || $method == 'HEAD') {
// Make sure we are not sending a request body.
$rawPost = '';
}
// Add default params.
$params += array('wt' => self::SOLR_WRITER);
$url = $this->_constructUrl($servlet, $params);
$id = $this->add_request_id($url);
// We assume we only authenticate the URL for other servlets.
list($cookie, $nonce) = acquia_search_auth_cookie($url);
if (empty($cookie)) {
throw new Exception('Invalid authentication string - subscription keys expired or missing.');
}
$request_headers += array('Cookie' => $cookie, 'User-Agent' => 'acquia_search/' . ACQUIA_SEARCH_VERSION);
list($data, $headers) = $this->_makeHttpRequest($url, $method, $request_headers, $rawPost, $timeout);
$response = new Apache_Solr_Response($data, $headers, $this->_createDocuments, $this->_collapseSingleValueArrays);
$hmac = acquia_search_extract_hmac($headers);
$code = (int) $response->getHttpStatus();
if ($code != 200) {
$message = $response->getHttpStatusMessage();
if ($code >= 400 && $code != 403 && $code != 404) {
// Add details, like Solr's exception message.
$message .= $response->getRawResponse();
}
throw new Exception('"' . $code . '" Status: ' . $message);
} elseif (!acquia_search_valid_response($hmac, $nonce, $data)) {
throw new Exception('Authentication of search content failed url: ' . $url);
}
return $response;
}
示例13: _sendRawPost
/**
* Central method for making a post operation against this Solr Server
*
* @param string $url
* @param string $rawPost
* @param float $timeout Read timeout in seconds
* @param string $contentType
* @return Apache_Solr_Response
*
* @throws Exception If a non 200 response status is returned
*/
protected function _sendRawPost($url, $rawPost, $timeout = FALSE, $contentType = 'text/xml; charset=UTF-8')
{
//set up the stream context for posting with file_get_contents
$context = stream_context_create(
array(
'http' => array(
// set HTTP method
'method' => 'POST',
// Add our posted content type
'header' => "Content-Type: $contentType",
// the posted content
'content' => $rawPost
)
)
);
// set the timeout if specified, without this I assume
// that the default_socket_timeout ini setting is used
if ($timeout !== FALSE && $timeout > 0.0)
{
// timeouts with file_get_contents seem to need
// to be halved to work as expected
$timeout = (float) $timeout / 2;
stream_context_set_option($context, 'http', 'timeout', $timeout);
}
//$http_response_header is set by file_get_contents
$response = new Apache_Solr_Response(@file_get_contents($url, false, $context), $http_response_header, $this->_createDocuments, $this->_collapseSingleValueArrays);
if ($response->getHttpStatus() != 200)
{
throw new Exception('"' . $response->getHttpStatus() . '" Status: ' . $response->getHttpStatusMessage(), $response->getHttpStatus());
}
return $response;
}
示例14: _sendRawPost
/**
* Central method for making a post operation against this Solr Server
*
* @param string $url
* @param string $rawPost
* @param string $contentType
* @return Apache_Solr_Response
*
* @throws Exception If a non 200 response status is returned
*/
private function _sendRawPost($url, $rawPost, $contentType = 'text/xml; charset=UTF-8')
{
//ensure content type is correct
stream_context_set_option($this->_postContext, 'http', 'header', 'Content-Type: ' . $contentType . "\r\n");
//set the content
stream_context_set_option($this->_postContext, 'http', 'content', $rawPost);
//$http_response_header is set by file_get_contents
$response = new Apache_Solr_Response(@file_get_contents($url, false, $this->_postContext), $http_response_header);
if ($response->getHttpStatus() != 200) {
throw new Exception('"' . $response->getHttpStatus() . '" Status: ' . $response->getHttpStatusMessage());
}
return $response;
}
示例15: _sendRawPost
/**
* Central method for making a post operation against this Solr Server
*
* @param string $url
* @param string $rawPost
* @param float $timeout Read timeout in seconds
* @param string $contentType
* @return Apache_Solr_Response
*
* @throws Exception If a non 200 response status is returned
*/
protected function _sendRawPost($url, $rawPost, $timeout = FALSE, $contentType = 'text/xml; charset=UTF-8')
{
list($output, $info) = $this->_curlGetContents($url, $rawPost, $timeout, $contentType);
$response = new Apache_Solr_Response($output, $info, $this->_createDocuments, $this->_collapseSingleValueArrays);
if ($response->getHttpStatus() != 200) {
throw new Exception('"' . $response->getHttpStatus() . '" Status: ' . $response->getHttpStatusMessage(), $response->getHttpStatus());
}
return $response;
}