Skip to content

Commit

Permalink
Merge pull request #1514 from Tobion/ignore-fragment
Browse files Browse the repository at this point in the history
ignore URI fragment when dereferencing
  • Loading branch information
mtdowling committed Jul 1, 2016
2 parents 502b400 + 4908639 commit 71960d8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
16 changes: 9 additions & 7 deletions src/Handler/CurlFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ private function getDefaultConf(EasyHandle $easy)
$conf = [
'_headers' => $easy->request->getHeaders(),
CURLOPT_CUSTOMREQUEST => $easy->request->getMethod(),
CURLOPT_URL => (string) $easy->request->getUri(),
CURLOPT_URL => (string) $easy->request->getUri()->withFragment(''),
CURLOPT_RETURNTRANSFER => false,
CURLOPT_HEADER => false,
CURLOPT_CONNECTTIMEOUT => 150,
Expand Down Expand Up @@ -495,12 +495,14 @@ private static function retryFailedRewind(

private function createHeaderFn(EasyHandle $easy)
{
if (!isset($easy->options['on_headers'])) {
$onHeaders = null;
} elseif (!is_callable($easy->options['on_headers'])) {
throw new \InvalidArgumentException('on_headers must be callable');
} else {
if (isset($easy->options['on_headers'])) {
$onHeaders = $easy->options['on_headers'];

if (!is_callable($onHeaders)) {
throw new \InvalidArgumentException('on_headers must be callable');
}
} else {
$onHeaders = null;
}

return function ($ch, $h) use (
Expand All @@ -512,7 +514,7 @@ private function createHeaderFn(EasyHandle $easy)
if ($value === '') {
$startingResponse = true;
$easy->createResponse();
if ($onHeaders) {
if ($onHeaders !== null) {
try {
$onHeaders($easy->response);
} catch (\Exception $e) {
Expand Down
4 changes: 2 additions & 2 deletions src/Handler/StreamHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ function () use ($context, $params) {

return $this->createResource(
function () use ($request, &$http_response_header, $context) {
$resource = fopen($request->getUri(), 'r', null, $context);
$resource = fopen((string) $request->getUri()->withFragment(''), 'r', null, $context);
$this->lastHeaders = $http_response_header;
return $resource;
}
Expand Down Expand Up @@ -425,7 +425,7 @@ private function add_debug(RequestInterface $request, &$options, $value, &$param
'bytes_transferred', 'bytes_max'];

$value = \GuzzleHttp\debug_resource($value);
$ident = $request->getMethod() . ' ' . $request->getUri();
$ident = $request->getMethod() . ' ' . $request->getUri()->withFragment('');
$this->addNotification(
$params,
function () use ($ident, $value, $map, $args) {
Expand Down

0 comments on commit 71960d8

Please sign in to comment.