Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ignore URI fragment when dereferencing #1514

Merged
merged 1 commit into from
Jul 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'])) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was only rewritten so phpstorm understands that $onHeaders can be a callable or null and does not mark this with an error.

$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