• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: POST message
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: POST message


  • Subject: Re: POST message
  • From: Jim Luther <email@hidden>
  • Date: Tue, 25 Oct 2005 15:38:36 -0700

On Oct 25, 2005, at 3:03 PM, Frederick Cheung wrote:


On 25 Oct 2005, at 21:50, Jan E. Schotsman wrote:

Thanks to help from this list I can download a query URL using the CFHTTPStream API (GET request).
One small problem remains: before I get the data I need I get 10 kB of JavaScript and page formatting. I don't believe a way exists to skip the first part of the download, or is there?



You can set the Range header to indicate which part of the file you want (check the http rfc for the exact syntax), however servers don't have to implement it.


Fred

Fred is correct and it's in section 14.35 of rfc2616 <http:// www.ietf.org/rfc/rfc2616.txt?number=2616>.


Here's the code to add a "Range" header to message (a variable of type CFHTTPMessageRef) to get the remainder of a resource starting at offset (a variable of type off_t):

    CFStringRef currentLengthString;

currentLengthString = CFStringCreateWithFormat (kCFAllocatorDefault, NULL, CFSTR("bytes=%qd-"), offset);
CFHTTPMessageSetHeaderFieldValue(message, CFSTR("Range"), currentLengthString);
CFRelease(currentLengthString);


One the wire, the "Range" header will look like this (if offset is exactly 10K):

	Range: bytes=10240-

There's no end to the range, so this requests everything up to the end of the resource.

In the response from the server, you'll get a 206 (Partial Content) status and a "Content-Range" header if the server returned a range. For example:

	Content-Range: bytes 10240-40692/40693

If you get a 200 (OK) response, then the server sent you the whole resource instead of the range.

Typically, you'd use a "Range" header in addition to a "If-Range" header if you are getting the rest of a resource you partially retrieved. The "If-Range" header will have an entity-tag or an HTTP- date that you got when you retrieved the first part of the resource.

- Jim
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: POST message
      • From: "Jan E. Schotsman" <email@hidden>
References: 
 >Re: POST message (From: "Jan E. Schotsman" <email@hidden>)
 >Re: POST message (From: Frederick Cheung <email@hidden>)

  • Prev by Date: Re: POST message
  • Next by Date: Re: POST message
  • Previous by thread: Re: POST message
  • Next by thread: Re: POST message
  • Index(es):
    • Date
    • Thread