在CLI模式下使用httparty gem
httparty -a post -H Content-Type:application/json -H Accept-Encoding:gzip,deflate "https://test.co.uk/search" -d '{ "requestAuditInfo ": { "agentCode ": "001 ", "requestPassword ": "PASSWORD", "requestDateTime ": "2018-08-03T23:52:31Z ", "requestID ": 1 },[...]'
在上述情况下,以及<{>> 被省略的-H Accept-Encoding:gzip,deflate
,post命令将返回:
Error 500: javax.servlet.ServletException: Filter [GZipCompressionFilter]: Could not find required filter class - uk.co.controller.filter.GZipCompressionFilter.class
从应用程序控制器操作运行时(同样,以及-H Accept-Encoding:gzip,deflate
被省略),响应具有更加清晰的信息(清理了敏感数据,出于可读性目的而中断):
#<HTTParty::Response:0x7fd4ebc81988 parsed_response="Error 500: javax.servlet.ServletException: Filter [GZipCompressionFilter]: Could not find required filter class - uk.co.controller.filter.GZipCompressionFilter.class\n",
@response=#<Net::HTTPInternalServerError 500 Internal Server Error readbody=true>,
@headers={"date"=>["Sat, 04 Aug 2018 00:08:28 GMT"],
"content-type"=>["text/html;charset=ISO-8859-1"],
"transfer-encoding"=>["chunked"],
"connection"=>["keep-alive"],
"set-cookie"=>["__cfduid=d5331e829a3bf88ad6c8eb42f8d697d071533341308; expires=Sun, 04-Aug-19 00:08:28 GMT; path=/; domain=.co.uk; HttpOnly"],
"$wsep"=>[""], "content-language"=>["en-US"], "x-powered-by"=>["Servlet/3.0"],
"expect-ct"=>["max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\""],
"server"=>["cloudflare"], "cf-ray"=>["444cca2c29834352-MXP"]}>
几个小时前该API 未遇到此错误。
这表明API是存在压缩问题的API-正确吗?或者,由于该服务倾向于提供压缩后的响应,我是否不能正确处理强制压缩响应?