Skip to content

Fix curl command of CurlFormatter when there is an user-agent header #82

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

Merged
merged 1 commit into from
Jun 28, 2017
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

- CookieUtil::parseDate to create a date from cookie date string

### Fixed

- Fix curl command of CurlFormatter when there is an user-agent header

## 1.5.0 - 2017-02-14

### Added
Expand Down
14 changes: 14 additions & 0 deletions spec/Formatter/CurlCommandFormatterSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,18 @@ function it_does_nothing_for_response(ResponseInterface $response)
{
$this->formatResponse($response)->shouldReturn('');
}

function it_formats_the_request_with_user_agent(RequestInterface $request, UriInterface $uri, StreamInterface $body)
{
$request->getUri()->willReturn($uri);
$request->getBody()->willReturn($body);

$uri->withFragment('')->shouldBeCalled()->willReturn('http://foo.com/bar');
$request->getMethod()->willReturn('GET');
$request->getProtocolVersion()->willReturn('1.1');
$uri->withFragment('')->shouldBeCalled()->willReturn('http://foo.com/bar');
$request->getHeaders()->willReturn(['user-agent'=>['foobar-browser']]);

$this->formatRequest($request)->shouldReturn("curl 'http://foo.com/bar' -A 'foobar-browser'");
}
}
2 changes: 1 addition & 1 deletion src/Formatter/CurlCommandFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private function getHeadersAsCommandOptions(RequestInterface $request)
}

if ('user-agent' === strtolower($name)) {
$command .= sprintf('-A %s', escapeshellarg($values[0]));
$command .= sprintf(' -A %s', escapeshellarg($values[0]));
continue;
}

Expand Down