I am trying to enable gzip compression on my service endpoints. My original rest service is a spring boot web application. Which I easily enabled the gzip thanks to this answer.
The problems starts when I try to integrate it with AWS public api. I'm using swagger integration.
If I don't do anything on public api, requests through postman or curl to public api never returns encoded response or headers related to encoding.
So I have tried passing the Accept-Encoding
header of request trough the public api to my original rest service by applying the specific example mappings as shown below:
{
"/brand/list": {
"get": {
"summary": "Get a list of brands",
"description": "List",
"operationId": "List",
"produces": [
"application/json",
"application/x-www-form-urlencoded",
"text/plain"
],
"parameters": [
{
"name": "Accept-Encoding",
"in": "header",
"required": false,
"type": "string"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/DataModelOfBrandCatalogue"
},
"headers": {
"Content-Encoding": {
"type": "string"
}
}
},
"400": ..., ...., "500"
},
"x-amazon-apigateway-integration": {
"uri": "http://original.service.com/brand/list",
"responses": {
"200": {
"statusCode": "200",
"responseParameters": {
"method.response.header.Content-Encoding": "integration.response.header.Content-Encoding"
}
},
"400": ..., ...., "500"
},
"requestParameters": {
"integration.request.header.Accept-Encoding": "method.request.header.Accept-Encoding",
"integration.request.header.Content-Type": "'application/json'"
},
"passthroughBehavior": "when_no_match",
"httpMethod": "GET",
"type": "http"
},
"tags": []
}
}
}
Though when I deploy this description, something interesting happens. When I do a curl request like below, the response is encoded indeed. If I remove Accept-Encoding
parameter from curl, the response is not encoded as expected. Everything's okay till here.
curl -X GET https://api.service.com/brand/list -H 'Cache-Control: no-cache' -H 'Accept-Encoding: gzip'
But when I go to postman, and make the same query (I'm sure they are same, as I have generated the curl command through POSTMAN's own tool - code
button) it's not getting any response back. Postman Console shows Error: incorrect header check
.
What am I missing? Is my strategy wrong? Or do I miss some details?
Edit: I thought the encoded response was correct, but when I add --compressed
to my curl
request, I noticed it's giving error below, so the encoding is not correct either.
curl: (61) Error while processing content unencoding: invalid block type