If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Finally, you've told the server that your app will accept its reply in a compressed form (myHttpWebRequest.Headers("Accept-Encoding") = "gzip,deflate"), so you need to decompress the data from the response stream. You can use the System.IO.Compression.GZipStream Class to perform the decompression on the fly.

I figured that reason of error is, streamResponse is null when passing as argument to streamCompressedResponse.CopyTo method.
So what is proper and efficient way to get that http response stream, decompress it using GZipStream and show its JSON output in RichTextBox?

I figured that reason of error is, streamResponse is null when passing as argument to streamCompressedResponse.CopyTo method.
So what is proper and efficient way to get that http response stream, decompress it using GZipStream and show its JSON output in RichTextBox?

Yep, good catch.

I'd probably write it something like this:

Code:

myHttpWebResponse = CType(myHttpWebRequest.GetResponse, HttpWebResponse)
Using deCompressedStream As New GZipStream(myHttpWebResponse.GetResponseStream(), CompressionMode.Decompress)
Using streamRead As New StreamReader(deCompressedStream)
RichTextBox1.Text = streamRead.ReadToEnd()
End Using
End Using
myHttpWebResponse.Close()

As you now have it sorted out, could you please do us a little favour, and mark the thread as Resolved?(this saves time reading for those of us who like to answer questions, and also helps those who search to find answers)

You can do it by clicking on "Thread tools" just above the first post in this thread, then "Mark thread resolved". (like various other features of this site, you need JavaScript enabled in your browser for this to work).

Advertiser Disclosure:
Some of the products that appear on this site are from companies from which QuinStreet receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. QuinStreet does not include all companies or all types of products available in the marketplace.