HttpWebRequest

C

csharpula csharp

Hello,
Is there a way somehow to read only part of the file via Http ? (Here is
the code that reads the whole file)

HttpWebRequest req =
(HttpWebRequest)HttpWebRequest.Create("http://x:8080/axis2/axis2-web/log
s/aaa.out");
req.Proxy.Credentials =
CredentialCache.DefaultNetworkCredentials;
HttpWebResponse resp =
(HttpWebResponse)req.GetResponse();

Stream streamReader = resp.GetResponseStream();


How can I have in the final stream just part of the file according to
some index?
Thanks
 
C

csharpula csharp

I read url from c# and not developing on asp.net - those solutions are
not good in my case. Any other ideas? Thanks a lot!
 
N

Nicholas Paldino [.NET/C# MVP]

Well, considering that the solution (to use the range header) was meant
for you to set on your HttpWebRequest, I don't see why that matters. You
need to add the header through the Header property, which exposes a
WebHeaderCollection instance, on which you will call the Add method.
 
M

Marc Gravell

that the solution (to use the range header) was meant for you to set on your HttpWebRequest

Precisely; the links were intended for reference in what the RANGE
header /means/ - not as example code. For illustration, the simple
"resume" example in the devx page would translate as:

req.Headers.Add("Range", "bytes=822603-");

The exact value depends on what you want to return...

Marc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top