473,395 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

http/1.1 decompress

Hi,

I'm writing an application who 'sniffs' port 80.
The sniffing works 'perfect', I receive a byte array with the data sent over
the port.
My problem is the following, when I write the array to a txt file most of
the content is encoded.
The only things that are readable are the http headers from which I can read
that Internet Explorer uses "content-encoding: gzip, deflate".

So I may conclude that I'll need to decompress the data I received.
This is easier said than done:).
I tried to decompress with GZipStream, DeflateStream (both from .NET 2.0)
and SharpZipLib.Gzip.GzipInputstream but neither of them want to decompress
my array.
In the beginning I received several errors about an incorrect magicnumber
and incorrect format. I thought why not add the gzip header
(31,139,8,0,0,0,0,0,0,0) at the start of my array.
..Net didn't throw any exceptions but it didn't decompress (the output is now
an empty file because the bytesread of my decompress stream is 0) my data
either.

Does anyone knows how that Internet Explorer performs the decompression or
how I can perform the decompression myself?

Thx in advance

Frederik.
Aug 25 '06 #1
4 3379
You've run into a rather rare animal there, Frederik, although I suppose
that at some point it's likely to catch on popularly, to save bandwidth.

I found a good article on the subject, which also links to some libraries
you can use:

http://www.15seconds.com/issue/020314.htm

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

It takes a tough man to make a tender chicken salad.
"Frederik Vanderhaegen" <fr*******************@pandora.bewrote in message
news:O5**************@TK2MSFTNGP05.phx.gbl...
Hi,

I'm writing an application who 'sniffs' port 80.
The sniffing works 'perfect', I receive a byte array with the data sent
over the port.
My problem is the following, when I write the array to a txt file most of
the content is encoded.
The only things that are readable are the http headers from which I can
read that Internet Explorer uses "content-encoding: gzip, deflate".

So I may conclude that I'll need to decompress the data I received.
This is easier said than done:).
I tried to decompress with GZipStream, DeflateStream (both from .NET 2.0)
and SharpZipLib.Gzip.GzipInputstream but neither of them want to
decompress my array.
In the beginning I received several errors about an incorrect magicnumber
and incorrect format. I thought why not add the gzip header
(31,139,8,0,0,0,0,0,0,0) at the start of my array.
.Net didn't throw any exceptions but it didn't decompress (the output is
now an empty file because the bytesread of my decompress stream is 0) my
data either.

Does anyone knows how that Internet Explorer performs the decompression or
how I can perform the decompression myself?

Thx in advance

Frederik.

Aug 25 '06 #2
Kevin,

I don't seem to be able to solve the decompress problem but I have another
possible solution for my problem.
Maybe you can help me with that.
I should be able to remove the content-encoding field from the header before
the request is send to the server =the server won't compress the message
and I can read the response.
So I think I should create a sort of proxy that checks outgoing messages for
the content-encoding field.

I should capture the messages before they're are being send to port 80,
adjust them and do a resend.

The only problem is that I'm not sure how I can create such a construction.

Do you have an idea how I can start?
Thx in advance

Frederik
"Kevin Spencer" <uc*@ftc.govschreef in bericht
news:Of**************@TK2MSFTNGP04.phx.gbl...
You've run into a rather rare animal there, Frederik, although I suppose
that at some point it's likely to catch on popularly, to save bandwidth.

I found a good article on the subject, which also links to some libraries
you can use:

http://www.15seconds.com/issue/020314.htm

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

It takes a tough man to make a tender chicken salad.
"Frederik Vanderhaegen" <fr*******************@pandora.bewrote in
message news:O5**************@TK2MSFTNGP05.phx.gbl...
>Hi,

I'm writing an application who 'sniffs' port 80.
The sniffing works 'perfect', I receive a byte array with the data sent
over the port.
My problem is the following, when I write the array to a txt file most of
the content is encoded.
The only things that are readable are the http headers from which I can
read that Internet Explorer uses "content-encoding: gzip, deflate".

So I may conclude that I'll need to decompress the data I received.
This is easier said than done:).
I tried to decompress with GZipStream, DeflateStream (both from .NET 2.0)
and SharpZipLib.Gzip.GzipInputstream but neither of them want to
decompress my array.
In the beginning I received several errors about an incorrect magicnumber
and incorrect format. I thought why not add the gzip header
(31,139,8,0,0,0,0,0,0,0) at the start of my array.
.Net didn't throw any exceptions but it didn't decompress (the output is
now an empty file because the bytesread of my decompress stream is 0) my
data either.

Does anyone knows how that Internet Explorer performs the decompression
or how I can perform the decompression myself?

Thx in advance

Frederik.


Aug 26 '06 #3
Thus wrote Frederik,
Kevin,

I don't seem to be able to solve the decompress problem but I have
another
possible solution for my problem.
Maybe you can help me with that.
I should be able to remove the content-encoding field from the header
before
the request is send to the server =the server won't compress the
message
and I can read the response.
So I think I should create a sort of proxy that checks outgoing
messages for
the content-encoding field.
I should capture the messages before they're are being send to port
80, adjust them and do a resend.

The only problem is that I'm not sure how I can create such a
construction.

Do you have an idea how I can start?
To avoid receiving compressed content, make sure *not* to send an Accept-Encoding
header with a value of "gzip" or "deflate". .NET 1.x has no built-in support
for compression, so just make sure you don't set the header in your code
explicitly. In .NET 2.0, set HttpWebRequest.AutomaticDecompression to DecompressionMethods.None.

Cheers,
--
Joerg Jooss
ne********@joergjooss.de
Aug 26 '06 #4
Hi Frederik,

I think I may have found something for you. Check out the articles in the
series below:

http://www.eggheadcafe.com/articles/20011226.asp

There is a compression library referenced in the articles that sounds like
what you need.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

It takes a tough man to make a tender chicken salad.
"Frederik Vanderhaegen" <fr*******************@pandora.bewrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Kevin,

I don't seem to be able to solve the decompress problem but I have another
possible solution for my problem.
Maybe you can help me with that.
I should be able to remove the content-encoding field from the header
before the request is send to the server =the server won't compress the
message and I can read the response.
So I think I should create a sort of proxy that checks outgoing messages
for the content-encoding field.

I should capture the messages before they're are being send to port 80,
adjust them and do a resend.

The only problem is that I'm not sure how I can create such a
construction.

Do you have an idea how I can start?
Thx in advance

Frederik
"Kevin Spencer" <uc*@ftc.govschreef in bericht
news:Of**************@TK2MSFTNGP04.phx.gbl...
>You've run into a rather rare animal there, Frederik, although I suppose
that at some point it's likely to catch on popularly, to save bandwidth.

I found a good article on the subject, which also links to some libraries
you can use:

http://www.15seconds.com/issue/020314.htm

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

It takes a tough man to make a tender chicken salad.
"Frederik Vanderhaegen" <fr*******************@pandora.bewrote in
message news:O5**************@TK2MSFTNGP05.phx.gbl...
>>Hi,

I'm writing an application who 'sniffs' port 80.
The sniffing works 'perfect', I receive a byte array with the data sent
over the port.
My problem is the following, when I write the array to a txt file most
of the content is encoded.
The only things that are readable are the http headers from which I can
read that Internet Explorer uses "content-encoding: gzip, deflate".

So I may conclude that I'll need to decompress the data I received.
This is easier said than done:).
I tried to decompress with GZipStream, DeflateStream (both from .NET
2.0) and SharpZipLib.Gzip.GzipInputstream but neither of them want to
decompress my array.
In the beginning I received several errors about an incorrect
magicnumber and incorrect format. I thought why not add the gzip header
(31,139,8,0,0,0,0,0,0,0) at the start of my array.
.Net didn't throw any exceptions but it didn't decompress (the output is
now an empty file because the bytesread of my decompress stream is 0) my
data either.

Does anyone knows how that Internet Explorer performs the decompression
or how I can perform the decompression myself?

Thx in advance

Frederik.



Aug 26 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Alan G Isaac | last post by:
I have an .zip archive of compressed files that I want to decompress. Using the zipfile module, I tried z=zipfile.ZipFile(local.zip) for zname in z.namelist(): localtxtfile='c:/puthere/'+zname...
2
by: enrio | last post by:
I have a string which I try to decompress: body = zlib.decompress(body) but I get zlib.error: Error -3 while decompressing data: incorrect header check However, I can write the string to...
4
by: Dante | last post by:
Hello, When I try to decompress a response from a web service I'm getting the error: "hexadecimal value 0x1F, is an invalid character. Line 1, position 1." The web server is an apache server....
0
by: newbie | last post by:
Hi Can anyone please tell me how I can get and decompress JPEGs from an URL? Thank you!
4
by: umberto | last post by:
Hello, I know that I can process txt files using ASP scrips. But there is a compressed text file (with Winzip) that I want to list on my web page. Is there possibility to decompress it on server...
0
by: JBear | last post by:
Can anyone tell me how to decompress a zip file containing multiple files (but no folder) using a class in the System.IO.Compression namespace? I'm trying to decompress a Google Earth KMZ file,...
1
by: Szeged | last post by:
I'm new to JavaScript. I have relatively large amounts of text (~200 kB) that I need to transfer to my web application every now and then. Using RAR, I get a 5:1 compression ratio on these files,...
2
by: Frederik Vanderhaegen | last post by:
Hi, I'm writing an application who captures everything that passes on port 80. The result op the capture is an byte array with the retrieved values. My problem is the following when i'm trying...
1
by: Carly | last post by:
Hello, I am just wondering if somebody can look on this piece of code and let me know what is wrong with DECOMPRESSION. Dim mystr As String = "flower power" 'deflate Dim mybytearray() As...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.