• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Content-Encoding

 
Cameron Park
Ranch Hand
Posts: 371
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am unclear about the header "Content-Encoding" and what its corresponding value does. When we setHeader to be "Content-Encoding", "x-gzip", does it send out the requested file in the zip format?
What is the differences between "x-gzip" and "gzip"?
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Cameron Park:
Hi, I am unclear about the header "Content-Encoding" and what its corresponding value does. When we setHeader to be "Content-Encoding", "x-gzip", does it send out the requested file in the zip format?

No. These MIME types are merely a label telling the browser what type of content you're sending. It is up to you to ensure that what you are sending actually matches the encoding you set.
If you'd like to see this in action then just do this little experiment. Write a one-line JSP

and check it out with a browser. Now try setting set the content type:

and check it out again. The second time round, you're telling the browser that you are going to send plain text. As a consequence, it makes no attempt interpreting the HTML tags and will show your HTML source.
What is the differences between "x-gzip" and "gzip"?

The difference is that all "x-" types are unregistered and experimental. I guess that support for "x-gzip" was retained even after proper registration of the "gzip" type and don't think there is any difference in practice. MIME types are governed by the Internet Engineering Task Force (IETF) RFCs. For a thorough overview, look at RFC 2045-2049.
- Peter
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic