Skip to content

Commit e3ef549

Browse files
committed
Merge branch 'curl-compressed'
2 parents c8ced33 + df6d3ce commit e3ef549

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

src/targets/shell/curl.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ module.exports = function (source, options) {
4444
code.push(opts.short ? '-0' : '--http1.0')
4545
}
4646

47+
if (headerHelpers.getHeader(source.allHeaders, 'accept-encoding')) {
48+
code.push('--compressed')
49+
}
50+
4751
// if multipart form data, we want to remove the boundary
4852
if (source.postData.mimeType === 'multipart/form-data') {
4953
const contentTypeHeaderName = headerHelpers.getHeaderName(source.headersObj, 'content-type')
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"method": "GET",
3+
"url": "http://mockbin.com/har",
4+
"headers": [
5+
{
6+
"name": "accept-encoding",
7+
"value": "deflate, gzip, br"
8+
}
9+
]
10+
}

test/targets/shell/curl.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@ module.exports = function (HTTPSnippet, fixtures) {
7474
result.should.eql('curl --request GET --url http://mockbin.com/request --http1.0')
7575
})
7676

77+
it('should use --compressed for requests that accept encodings', function () {
78+
const result = new HTTPSnippet(fixtures.curl.compression).convert('shell', 'curl', {
79+
indent: false
80+
})
81+
82+
result.should.be.a.String()
83+
result.should.eql("curl --request GET --url http://mockbin.com/har --compressed --header 'accept-encoding: deflate, gzip, br'")
84+
})
85+
7786
it('should use custom indentation', function () {
7887
const result = new HTTPSnippet(fixtures.requests.full).convert('shell', 'curl', {
7988
indent: '@'

0 commit comments

Comments
 (0)