Last active
December 19, 2015 01:48
-
-
Save dkuebric/5877999 to your computer and use it in GitHub Desktop.
quick patch to provide tracing coverage to Solarium
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function execute($request, $endpoint) | |
{ | |
if (is_callable('oboe_log')) { | |
oboe_log('Solarium', 'entry', array('IsService'=>'1')); | |
} | |
$client = $this->getZendHttp(); | |
$client->resetParameters(); | |
switch ($request->getMethod()) { | |
case Request::METHOD_GET: | |
$client->setMethod(\Zend_Http_Client::GET); | |
$client->setParameterGet($request->getParams()); | |
break; | |
case Request::METHOD_POST: | |
$client->setMethod(\Zend_Http_Client::POST); | |
if ($request->getFileUpload()) { | |
$this->prepareFileUpload($client, $request); | |
} else { | |
$client->setParameterGet($request->getParams()); | |
$client->setRawData($request->getRawData()); | |
$request->addHeader('Content-Type: text/xml; charset=UTF-8'); | |
} | |
break; | |
case Request::METHOD_HEAD: | |
$client->setMethod(\Zend_Http_Client::HEAD); | |
$client->setParameterGet($request->getParams()); | |
break; | |
default: | |
throw new OutOfBoundsException('Unsupported method: ' . $request->getMethod()); | |
break; | |
} | |
$client->setUri($endpoint->getBaseUri() . $request->getHandler()); | |
$client->setHeaders($request->getHeaders()); | |
$this->timeout = $endpoint->getTimeout(); | |
$response = $client->request(); | |
$ret = $this->prepareResponse( | |
$request, | |
$response | |
); | |
if (is_callable('oboe_log')) { | |
oboe_log('Solarium', 'exit', array('RemoteURL'=>$client->getUri(true))); | |
} | |
return $ret; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment