Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7521877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:21:25+00:00 2026-05-30T02:21:25+00:00

I need to send a POST request to a web server and be able

  • 0

I need to send a POST request to a web server and be able to read the response sent by said server.
I tried using the HTTPBuilder lib with this code :

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()}"
    }

I get an exception when this code gets executed :

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
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    158 | read      in     ''
|    116 | read . .  in java.util.zip.GZIPInputStream
|    138 | read      in org.apache.http.conn.EofSensorInputStream
|    184 | read . .  in java.io.InputStreamReader
|    140 | read      in java.io.Reader

I turned the debug on for wire and headers and this is what I get :

2012-01-06 16:50:12,219 ["http-bio-8080"-exec-2] DEBUG http.wire  - >> "Accept: */*[EOL]"
2012-01-06 16:50:12,219 ["http-bio-8080"-exec-2] DEBUG http.wire  - >> "Content-Length: 160[EOL]"
2012-01-06 16:50:12,219 ["http-bio-8080"-exec-2] DEBUG http.wire  - >> "Content-Type: application/x-www-form-urlencoded[EOL]"
2012-01-06 16:50:12,219 ["http-bio-8080"-exec-2] DEBUG http.wire  - >> "Host: myServer[EOL]"
2012-01-06 16:50:12,219 ["http-bio-8080"-exec-2] DEBUG http.wire  - >> "Proxy-Connection: Keep-Alive[EOL]"
2012-01-06 16:50:12,219 ["http-bio-8080"-exec-2] DEBUG http.wire  - >> "Cookie: ASPSESSIONIDSSTTACTA=NFJKHEDRFGTKCGFEHGFKOANP[EOL]"
2012-01-06 16:50:12,219 ["http-bio-8080"-exec-2] DEBUG http.wire  - >> "Cookie2: $Version=1[EOL]"
2012-01-06 16:50:12,219 ["http-bio-8080"-exec-2] DEBUG http.wire  - >> "Accept-Encoding: gzip,deflate[EOL]"
2012-01-06 16:50:12,219 ["http-bio-8080"-exec-2] DEBUG http.wire  - >> "[EOL]"
2012-01-06 16:50:12,219 ["http-bio-8080"-exec-2] DEBUG http.headers  - >> POST myUrl HTTP/1.1
2012-01-06 16:50:12,219 ["http-bio-8080"-exec-2] DEBUG http.headers  - >> Accept: */*
2012-01-06 16:50:12,219 ["http-bio-8080"-exec-2] DEBUG http.headers  - >> Content-Length: 160
2012-01-06 16:50:12,219 ["http-bio-8080"-exec-2] DEBUG http.headers  - >> Content-Type: application/x-www-form-urlencoded
2012-01-06 16:50:12,219 ["http-bio-8080"-exec-2] DEBUG http.headers  - >> Host: myServer
2012-01-06 16:50:12,219 ["http-bio-8080"-exec-2] DEBUG http.headers  - >> Proxy-Connection: Keep-Alive
2012-01-06 16:50:12,219 ["http-bio-8080"-exec-2] DEBUG http.headers  - >> Cookie: ASPSESSIONIDSSTTACTA=NFJKHEDRFGTKCGFEHGFKOANP
2012-01-06 16:50:12,219 ["http-bio-8080"-exec-2] DEBUG http.headers  - >> Cookie2: $Version=1
2012-01-06 16:50:12,219 ["http-bio-8080"-exec-2] DEBUG http.headers  - >> Accept-Encoding: gzip,deflate
2012-01-06 16:50:12,219 ["http-bio-8080"-exec-2] DEBUG http.wire  - >> "postbody"
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.wire  - << "HTTP/1.1 200 OK[EOL]"
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.wire  - << "Date: Fri, 06 Jan 2012 15:50:14 GMT[EOL]"
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.wire  - << "Server: Microsoft-IIS/6.0[EOL]"
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.wire  - << "X-Powered-By: ASP.NET[EOL]"
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.wire  - << "Content-Type: text/html[EOL]"
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.wire  - << "Cache-control: private[EOL]"
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.wire  - << "Via: 1.1 BAYEC-BC-20[EOL]"
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.wire  - << "Transfer-Encoding: chunked[EOL]"
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.wire  - << "Proxy-Connection: Keep-Alive[EOL]"
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.wire  - << "Connection: Keep-Alive[EOL]"
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.wire  - << "Content-Encoding: gzip[EOL]"
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.wire  - << "[EOL]"
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.headers  - << HTTP/1.1 200 OK
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.headers  - << Date: Fri, 06 Jan 2012 15:50:14 GMT
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.headers  - << Server: Microsoft-IIS/6.0
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.headers  - << X-Powered-By: ASP.NET
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.headers  - << Content-Type: text/html
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.headers  - << Cache-control: private
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.headers  - << Via: 1.1 BAYEC-BC-20
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.headers  - << Transfer-Encoding: chunked
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.headers  - << Proxy-Connection: Keep-Alive
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.headers  - << Connection: Keep-Alive
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.headers  - << Content-Encoding: gzip
[Date: Fri, 06 Jan 2012 15:50:14 GMT, Server: Microsoft-IIS/6.0, X-Powered-By: ASP.NET, Content-Type: text/html, Cache-control: private, Via: 1.1 BAYEC-BC-20, Transfer-Encoding: chunked, Proxy-Connection: Keep-Alive, Connection: Keep-Alive, Content-Encoding: gzip]
Content-Type: text/html
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.wire  - << "226[EOL]"
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.wire  - << "[0x1f]"
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.wire  - << "[0x8e]"
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.wire  - << "[0x2]"
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.wire  - << "[0x0]"
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.wire  - << "[0x0][0x0][0x0][0x0][0x4][0xb]"
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.wire  - << "[0x9c]S[0xc1][0x8e][0xda]0[0x10]G[0xbd]W[0xda]ps[0xe9][0xa5][0xc1]E[0xd5][0xaa]K[0xeb][0xa4]Zh[0x16]![0x1]BI[0xee][0xc8]$[0x3][0xb1]j[0x92]`O[0x10]|[0xf2][0xee]W[0xd4][0xb1][0x3][0x82][0xec][0xa5][0xad][0x1e4]9[0xf6]x[0xe6]y[0xde][0x9b][0x99][0x87][0xf][0xc84][0x10][0xf6][0xd1][0xf7][0xf9]N[0xf1]2[0x17][0x8fa]H [0x8][0xfb]Z[0x93][0x1c][0xcc]'[0xb9][0xf0][0xfd][0xf0][0xa1][0xf5]"v[0xb5]K[0x1b][0x93][0xce][0xd2]y[0x14][0xc6][\r][\n]"
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.wire  - << "Y+[0xd8]*80[0xea]l[0xd6][0x85]IQ[0xfe]&[\n]"
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.wire  - << "d[0xe0]i<K[0xd0][0x5][0x034]z[0xa4]0[0xa23e][0x81]G[0xc7]i[0x9a][0xac][0x9e][0xa7]QB[0xed][0xe5] [0xd3][0xda]#x[0xae]![0xf0][0x10]NH[0xdb][0xb3]y[0x95][0x15][0xb8][0x97][0xe6][0xdf][0xbe]W[0x0][0xcf][0xbb][0xed][0x1e][0x90][0x93][0x2][0xb1][0xf6][0xe1][0xd0][0x88]c[0xe0]M[0xcaa][0x12][0xa1]D?5[0x8][0x1e][0xc9][0xdc][0xa9][0x83]j!~[0x90][0xac][0xe0]J[0x3][0x6]BW[0xfe][0xd3][0xd3][0xe3][0xc8][0x1f]z[0x1d][0x18][\n]"
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.wire  - << "[0x94][0x10][0xc6]fz[0xaf][0xba][0x91][0xc68][0xd1]P&[0x92][0xf9b][0xbc][0xf][0xcdd][0x1b][0x2][0xa3][0xee][0xd6]1[0xa2]7)l[0xaa][0xfc][0xdc][0x1][0x14]_[0xef][0xa3]?[0xc1][0xe9]53[0xb2]T[0xe5]=[0x18][0x19]~[0xf9]6[0x1a]=2j[0x2][0x1c] [0xcf2][0x8d]Q{S[0xa9][0x1c]T[0xe0][\r]M[0xe6][0x92]k[0x1d]xY[0xd5]Hch[0x94][0xcbd][0xe6]M[0x97](a[0xa8]B[0x86]9[0xc9][0xee][0x9d][0x0][0x5]([0xf0]B[0xa6]QU[0xe5].L[0x5]*`[0xb4];[0x19][0x6]y[0x1b][0xe5]r[0xb5][0x9c5]fF;[[0x85]V[0xc1][0xef][0x94]n[0x10][0xf5]`[0x83][0xc1a][0xd4]Qd[0xa0][0x7][e[0xcb][0x93]L[0xe2][0xd9]*M(o[0xb0][0x82][0x13]d[0xfa] [0x7]\[0xd7]?[0xcb]foj[0x1d]82^[0xb8][0xfc]5#[0x1a][0xb8][0xca][\n]"
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.wire  - << "Fyx[0xed][0x95][0xeb]#wX/[0xf1]J[0xbf][0xc1]Y[0x99][0xec]dsq[0xe2]xPT[0x17]"f[0xf7][0x1d7]b<7h[0x84]|[0xaf][0xc6]4ZF[0xf1]l[0xf2][0x9f][0xa8][0xb1]i;[0xdb][0x1d]}[0x91]5H[0xc8]L[0xf][0x9][0x8d][0xa2]4[0x9b][0xac][0xca][0xa1][0xed]Fe[0x1a]k[0xab][0xaa]=9[0xae][0xbb][0xe3]NUM[\r][0x8d][0x19][0x1e][0xfd].[0x9]j[0xb]!Z\(;[0x1d][0xba]'o[0x90][0xaf][0xec]>;[0x8f]q[0xec]B[0xc7][0xe9]z61[0x93][0xd3]3[0x8f]&[0xd1]4J[0xa3]y[0xcf][0x9c][0xbc][0xc4][0xeb]h[0x9c9][0x92][0x9e][0xd9][0x80],V[0xf3]"
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.wire  - << "[0xa4]on[0xbcd][0x17][0xc9][0xaf2]o[0xc1e][0x1b][0xdc][0x16][0xa5][0x3][0xca1]7SB[0xdb]9t[0x489][0xfd][0x1][0x0][0x0][0xff][0xff]"
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.wire  - << "[\r]"
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.wire  - << "[\n]"
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.wire  - << "0[EOL]"
2012-01-06 16:50:15,687 ["http-bio-8080"-exec-2] DEBUG http.wire  - << "[EOL]"

So I guess the problem comes from the fact that the response is sent with :

Transfer-Encoding: chunked
Content-Encoding: gzip

Is there another way to do this ?
Am I doing it wrong ?
I tried googling for some time and did not find a good lead.
It seems to me that the HTTPBuilder lib is getting the entity content after the end of the closure but once I am out of that closure, I cannot access the entity content (exception is : Cannot access closed stream)

I really would appreciate help on this one 😉

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T02:21:26+00:00Added an answer on May 30, 2026 at 2:21 am

    Try using HTTPBuilder’s setContentEncoding() method.

    http.contentEncoding = ContentEncoding.Type.GZIP
    

    That should solve your problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hallo, I need to send a request to a page (POST) and then, I
I need to post raw xml to a site and read the response. With
How can I allow a specific server/url to send for example a post request
I need to send raw data in the body of a POST request to
I need to make POST request to REST web-service with header params and form
I need to send PUT and DELETE along with POST, GET to a REST
I need send certain attributes(say, human readable user name) from server to client after
I need to send a very specific (non-standard) string to an FTP server: dir
I need to send a CSV file in HTTP response. How can I set
I'm trying to send json string in the get request to the server, here

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.