HttpWebRequest

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • csharpula csharp

    #1

    HttpWebRequest

    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.Crede ntials =
    CredentialCache .DefaultNetwork Credentials;
    HttpWebResponse resp =
    (HttpWebRespons e)req.GetRespon se();

    Stream streamReader = resp.GetRespons eStream();


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



    *** Sent via Developersdex http://www.developersdex.com ***
  • Marc Gravell

    #2
    Re: HttpWebRequest

    I'd guess at adding a RANGE header, but it isn't guaranteed to be
    supported by the server.

    http://www.w3.org/Protocols/rfc2616/....html#sec14.35

    Marc


    Comment

    • Marc Gravell

      #3
      Re: HttpWebRequest

      Another walkthrough:



      Marc

      Comment

      • csharpula csharp

        #4
        Re: HttpWebRequest

        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!



        *** Sent via Developersdex http://www.developersdex.com ***

        Comment

        • Nicholas Paldino [.NET/C# MVP]

          #5
          Re: HttpWebRequest

          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
          WebHeaderCollec tion instance, on which you will call the Add method.


          --
          - Nicholas Paldino [.NET/C# MVP]
          - mvp@spam.guard. caspershouse.co m

          "csharpula csharp" <csharpula@yaho o.comwrote in message
          news:OdlTGdxQIH A.2208@TK2MSFTN GP06.phx.gbl...
          >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!
          >
          >
          >
          *** Sent via Developersdex http://www.developersdex.com ***

          Comment

          • Marc Gravell

            #6
            Re: HttpWebRequest

            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=8226 03-");

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

            Marc

            Comment

            Working...