Skip to content

Commit 05aea15

Browse files
committed
Fix curl command of CurlFormatter when there is an user-agent header
1 parent aa70fb8 commit 05aea15

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77

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

10+
### Fixed
11+
12+
- Fix curl command of CurlFormatter when there is an user-agent header
13+
1014
## 1.5.0 - 2017-02-14
1115

1216
### Added

spec/Formatter/CurlCommandFormatterSpec.php

+14
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,18 @@ function it_does_nothing_for_response(ResponseInterface $response)
5858
{
5959
$this->formatResponse($response)->shouldReturn('');
6060
}
61+
62+
function it_formats_the_request_with_user_agent(RequestInterface $request, UriInterface $uri, StreamInterface $body)
63+
{
64+
$request->getUri()->willReturn($uri);
65+
$request->getBody()->willReturn($body);
66+
67+
$uri->withFragment('')->shouldBeCalled()->willReturn('http://foo.com/bar');
68+
$request->getMethod()->willReturn('GET');
69+
$request->getProtocolVersion()->willReturn('1.1');
70+
$uri->withFragment('')->shouldBeCalled()->willReturn('http://foo.com/bar');
71+
$request->getHeaders()->willReturn(['user-agent'=>['foobar-browser']]);
72+
73+
$this->formatRequest($request)->shouldReturn("curl 'http://foo.com/bar' -A 'foobar-browser'");
74+
}
6175
}

src/Formatter/CurlCommandFormatter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private function getHeadersAsCommandOptions(RequestInterface $request)
6868
}
6969

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

0 commit comments

Comments
 (0)