小编ser*_*ty2的帖子

Groovy HTTPBuilder:从GZIPed Chunked响应中获取实体内容

我需要向Web服务器发送POST请求,并能够读取所述服务器发送的响应.我试着用这个代码使用HTTPBuilder lib:

def http = new HTTPBuilder('http://myServer/')
http.setProxy("Proxy_IP", 8080, "http")
postBody = [cmd:'e',format:'sep',c:'a',b:'b',t:'u',r:'r',kl:'lop']

    http.post( body: postBody,
               requestContentType: URLENC ){ resp ->
     HttpEntity he = resp.getEntity()
     println "${resp.getAllHeaders()}"
     println he.getContentType()
     println "${resp.getEntity().getContent()}"
    }
Run Code Online (Sandbox Code Playgroud)

执行此代码时出现异常:

ERROR errors.GrailsExceptionResolver  - EOFException occurred when processing request: [GET] /PROJECT/home/index
Unexpected end of ZLIB input stream. Stacktrace follows:
Message: Unexpected end of ZLIB input stream
    Line | Method
->>  240 | fill      in java.util.zip.InflaterInputStream
- - - - - - - - - - - - - …
Run Code Online (Sandbox Code Playgroud)

groovy gzip chunked-encoding httpbuilder

7
推荐指数
1
解决办法
3734
查看次数

标签 统计

chunked-encoding ×1

groovy ×1

gzip ×1

httpbuilder ×1