Download partial file using Content-Range

Last post 05-05-2008 3:37 PM by BarryR. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 05-01-2008 9:21 PM

    Download partial file using Content-Range

     Hi,

       I am trying to download partial contents of a file using "Content-Range" header in the GET request.

     

    GET /84Zl_uui~nc7uuQvnB6~GIlViu0K~vNh-6mtpR2~B51SOgI/App/User/temp/tt.txt HTTP/1.1\r\n 

      Content-Range: bytes 2-3/4\r\n

     

    The file tt.txt is of size 4 bytes.

    However no matter what range I give, I always get the entire file of 4 bytes and not the number of bytes asked for.

    Any Ideas?

    I have an ethereal trace for this also.

     

    Thanks

    Hemant 

      
     

  • 05-02-2008 2:31 PM In reply to

    • BarryR
    • Top 10 Contributor
    • Joined on 07-20-2007
    • San Diego
    • Posts 612

    Re: Download partial file using Content-Range

     Can you please send me the Ethereal (Wireshark) raw dump in a private message.  I want to make sure your headers are correct.  It seems to be working ok for me so perhaps there is a small error in the request header.

    Regards,
       Barry R.

    IM Support (Feel free to add me)

    MSN: barryruffner@msn.com
    Gmail: barryruffner@gmail.com
  • 05-02-2008 5:28 PM In reply to

    Re: Download partial file using Content-Range

    Hi Barry,

    Was getting an error in posting a private message. So could not send it that way. 

      Attached are the 2 frames (GET and its response).

    Want to download bytes 2 and 3 of file tt.txt which is 4 bytes long.

    Thanks for your help. Let me know if you need any more info or want me to try some stuff.

    Hemant

     

    Frame 72 (204 bytes on wire, 204 bytes captured)

    - SNIP -

    Hypertext Transfer Protocol
        GET /84Zl_uui~nc7uuQvnB6~GIlViu0K~vNh-6mtpR2~B51SOgI/CloudStorage/user1/temp/tt.txt HTTP/1.1\r\n
        Content-Range: bytes 2-3/4\r\n
        Host: node1.nirvanix.com\r\n
        \r\n

    0000  00 00 0c 07 ac 00 00 14 22 4f 97 88 08 00 45 00   ........"O....E.
    0010  00 be 41 b8 40 00 80 06 00 00 0a b4 9d 6e ce fb   ..A.@........n..
    0020  fe 11 10 65 00 50 cf 7d fd 49 83 bb ce d9 50 18   ...e.P.}.I....P.
    0030  fe 61 75 e0 00 00 47 45 54 20 2f 38 34 5a 6c 5f   .au...GET /84Zl_
    0040  75 75 69 7e 6e 63 37 75 75 51 76 6e 42 36 7e 47   uui~nc7uuQvnB6~G
    0050  49 6c 56 69 75 30 4b 7e 76 4e 68 2d 36 6d 74 70   IlViu0K~vNh-6mtp
    0060  52 32 7e 42 35 31 53 4f 67 49 2f 43 6c 6f 75 64   R2~B51SOgI/Cloud
    0070  53 74 6f 72 61 67 65 2f 75 73 65 72 31 2f 74 65   Storage/user1/te
    0080  6d 70 2f 74 74 2e 74 78 74 20 48 54 54 50 2f 31   mp/tt.txt HTTP/1
    0090  2e 31 0d 0a 43 6f 6e 74 65 6e 74 2d 52 61 6e 67   .1..Content-Rang
    00a0  65 3a 20 62 79 74 65 73 20 32 2d 33 2f 34 0d 0a   e: bytes 2-3/4..
    00b0  48 6f 73 74 3a 20 6e 6f 64 65 31 2e 6e 69 72 76   Host: node1.nirv
    00c0  61 6e 69 78 2e 63 6f 6d 0d 0a 0d 0a               anix.com....
    No.     Time        Source                Destination           Protocol Info
    -- SNIP --        HTTP     HTTP/1.1 200 OK  (text/plain)

    Frame 73 (468 bytes on wire, 468 bytes captured)

     -- SNIP --

    Transmission Control Protocol, Src Port: http (80), Dst Port: 4197 (4197), Seq: 1, Ack: 151, Len: 414
    Hypertext Transfer Protocol
        HTTP/1.1 200 OK\r\n
        Date: Thu, 01 May 2008 21:13:31 GMT\r\n
        Server: Microsoft-IIS/6.0\r\n
        X-Powered-By: ASP.NET\r\n
        X-AspNet-Version: 2.0.50727\r\n
        Content-Length: 4
        Content-Transfer-Encoding: binary\r\n
        Accept-Ranges: bytes\r\n
        Content-MD5: CY9rzUYh03PK3k6DJie09g==\r\n
        Cache-Control: private, must-revalidate, max-age=0\r\n
        Last-Modified: Thu, 25 Oct 2007 17:59:00 GMT\r\n
        ETag: "1997a018-92959349"\r\n
        Vary: *\r\n
        Content-Type: text/plain\r\n
        \r\n
    Line-based text data: text/plain

    0000  00 14 22 4f 97 88 00 17 0f ac 10 00 08 00 45 00   .."O..........E.
    0010  01 c6 4c 95 40 00 72 06 45 6d ce fb fe 11 0a b4   ..L.@.r.Em......
    0020  9d 6e 00 50 10 65 83 bb ce d9 cf 7d fd df 50 18   .n.P.e.....}..P.
    0030  fe bb 09 b7 00 00 48 54 54 50 2f 31 2e 31 20 32   ......HTTP/1.1 2
    0040  30 30 20 4f 4b 0d 0a 44 61 74 65 3a 20 54 68 75   00 OK..Date: Thu
    0050  2c 20 30 31 20 4d 61 79 20 32 30 30 38 20 32 31   , 01 May 2008 21
    0060  3a 31 33 3a 33 31 20 47 4d 54 0d 0a 53 65 72 76   :13:31 GMT..Serv
    0070  65 72 3a 20 4d 69 63 72 6f 73 6f 66 74 2d 49 49   er: Microsoft-II
    0080  53 2f 36 2e 30 0d 0a 58 2d 50 6f 77 65 72 65 64   S/6.0..X-Powered
    0090  2d 42 79 3a 20 41 53 50 2e 4e 45 54 0d 0a 58 2d   -By: ASP.NET..X-
    00a0  41 73 70 4e 65 74 2d 56 65 72 73 69 6f 6e 3a 20   AspNet-Version:
    00b0  32 2e 30 2e 35 30 37 32 37 0d 0a 43 6f 6e 74 65   2.0.50727..Conte
    00c0  6e 74 2d 4c 65 6e 67 74 68 3a 20 34 0d 0a 43 6f   nt-Length: 4..Co
    00d0  6e 74 65 6e 74 2d 54 72 61 6e 73 66 65 72 2d 45   ntent-Transfer-E
    00e0  6e 63 6f 64 69 6e 67 3a 20 62 69 6e 61 72 79 0d   ncoding: binary.
    00f0  0a 41 63 63 65 70 74 2d 52 61 6e 67 65 73 3a 20   .Accept-Ranges:
    0100  62 79 74 65 73 0d 0a 43 6f 6e 74 65 6e 74 2d 4d   bytes..Content-M
    0110  44 35 3a 20 43 59 39 72 7a 55 59 68 30 33 50 4b   D5: CY9rzUYh03PK
    0120  33 6b 36 44 4a 69 65 30 39 67 3d 3d 0d 0a 43 61   3k6DJie09g==..Ca
    0130  63 68 65 2d 43 6f 6e 74 72 6f 6c 3a 20 70 72 69   che-Control: pri
    0140  76 61 74 65 2c 20 6d 75 73 74 2d 72 65 76 61 6c   vate, must-reval
    0150  69 64 61 74 65 2c 20 6d 61 78 2d 61 67 65 3d 30   idate, max-age=0
    0160  0d 0a 4c 61 73 74 2d 4d 6f 64 69 66 69 65 64 3a   ..Last-Modified:
    0170  20 54 68 75 2c 20 32 35 20 4f 63 74 20 32 30 30    Thu, 25 Oct 200
    0180  37 20 31 37 3a 35 39 3a 30 30 20 47 4d 54 0d 0a   7 17:59:00 GMT..
    0190  45 54 61 67 3a 20 22 31 39 39 37 61 30 31 38 2d   ETag: "1997a018-
    01a0  39 32 39 35 39 33 34 39 22 0d 0a 56 61 72 79 3a   92959349"..Vary:
    01b0  20 2a 0d 0a 43 6f 6e 74 65 6e 74 2d 54 79 70 65    *..Content-Type
    01c0  3a 20 74 65 78 74 2f 70 6c 61 69 6e 0d 0a 0d 0a   : text/plain....
    01d0  74 65 73 74                                       test
    No.     Time        Source                Destination           Protocol Info
         -- SNIP --        TCP      4191 > http [ACK] Seq=2568 Ack=6411 Win=64836 [TCP CHECKSUM INCORRECT] Len=0


     

     

     

  • 05-05-2008 3:37 PM In reply to

    • BarryR
    • Top 10 Contributor
    • Joined on 07-20-2007
    • San Diego
    • Posts 612

    Re: Download partial file using Content-Range

    The problem with your request was your header name.  The Content-Range is returned to you telling you what was downloaded.   The only time Content-Range would be used by you would be in a Partial file upload.  The Range request is what you are looking for as show below:


    Range: 2-3\r\n\

    -- EDIT --
    Or you can be more explicit as it states in the RFC and pass:

    Range: bytes=2-3\r\n



    You can read more about this in the HTTP 1.1 RFC at: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35

    Regards,
       Barry R.

    IM Support (Feel free to add me)

    MSN: barryruffner@msn.com
    Gmail: barryruffner@gmail.com
    Filed under: , ,
Page 1 of 1 (4 items)