• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Cannot correctly receive a GZIP response and translate to string.

Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, i'm hoping some of you guys can help me with my problem. Unfortunately I need to roll my own HTTPClient. I have spent quite sometime researching sockets and have a rough client working. It grabs text/html just fine. However, as soon as I try to get a response that is of Encoding-Type: gzip I cannot seem to get the ByteArray to unzip. I get the following error: java.io.IOException: Not in GZIP format

I know it has gotta be how i'm storing the zipped data that might be the issue. I have noticed that the header for content-type tells me the length should be 12342 however after getting all the data my ByteBuffer has a capacity of 13245. That seems a bit strange?

I was hoping you guys would not mind looking at my code see if it looks logically correct?

I have embedded comments in code to show what i'm doing any ideas about why my ByteBuffer.capacity would be larger than header states it should be? This is the same when I pull text/html responses the ByteBuffer.capacity is larger than content length? So, i'm hoping if I figure this out this will fix my GZIP issue!

So, I have found if I take the ByteBuffer and convert it into string and then get the length its correct? What is inside the ByteBuffer that's being stripped when its converted to as string?
steve labar
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, here is the format of the bytes of the gzip data before attempting to pass it into the GZIPInputStream.

//-117, 8, 0, 0, 0, 0, 0, 0, 3, -78, 81, 116, -15, 119, 14, -119, 12, 112, 85, -56, 40, -55, -51, 81, 8, 8, 117, -14, -15, 116, 86, 80, -46, -43, -41, 15, 55, 118, -42, -41, 119, 9, 113, 81, -120, -16, 8, -15, -11, 81, 48, -44, 51, 80,
Come have lunch with me Arthur. Adventure will follow. This tiny ad:
the value of filler advertising in 2020
    Bookmark Topic Watch Topic
  • New Topic