• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Apache Http Client Request Header

 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to make an Http Post request call to a Http server. I'm using the Apache Http Client library to write the client that connects to the server:



The call reaches the server, but surprisingly I'm facing two issues:

1. the header that I set, Content-Encoding is missing when the request arrives at the server.

Here is what I see as part of the request headers on the server:

Map(Charset -> UTF-8, Connection -> Keep-Alive, Content-Length -> 5530, Content-Type -> application/octet-stream, User-Agent -> Apache-HttpClient/4.1.1 (java 1.5), Host -> MyComputer:9000)

2. It fails when trying to unzip the contents using Gunzip utility that I have on the server.

Any ideas?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using GZIP for transfer compression isn't achieved by just setting that header, nor -would I imagine- would it be easy to get at the gzipped data on the server (because it's automatically ungzipped).

See the "Custom protocol interceptors" example at http://hc.apache.org/httpcomponents-client-4.2.x/examples.html
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is the getBytePaylod method that does the GZip compression on the client!



I noticed that on the server, the length of the content is 5330 equal to the uncompressed file size. The server now fails wiht the exception saying that the input fed is not a GZIP file:



I traced it back to the source code on the server where the error on the server is thrown. Here is a code snippet of that. It fails saying that the Gzip Magic number is missing?

 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you used a network monitor to ascertain whether or not the content *is* gzipped in transfer?
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:Have you used a network monitor to ascertain whether or not the content *is* gzipped in transfer?



I have not tried that. How could I do that? Right now, I'm running the client from within intelliJ!
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
WireShark is a good one.
 
reply
    Bookmark Topic Watch Topic
  • New Topic