Professional Web Applications Themes

Cocoa: does stringWithContentsOfURL do conditional GETs ? - Mac Programming

I'm making use of stringWithContentsOfURL in a client which does repeated downloading of an RSS feed (don't worry -- I don't thrash the server). It's really useful and considerably simplifies my application. However, the person who runs the site my application looks at has pointed out that my client should be checking the 'Last-Modified' header. I don't know if it is or not. Is it ? If not, how much of an HTTP client do I have to write to do this correctly ? If there's any doubt, I'm talking about the things discussed at [url]http://fishbowl.pastiche.org/archives/001132.html[/url]...

  1. #1

    Default Cocoa: does stringWithContentsOfURL do conditional GETs ?

    I'm making use of stringWithContentsOfURL in a client which does
    repeated downloading of an RSS feed (don't worry -- I don't
    thrash the server). It's really useful and considerably
    simplifies my application. However, the person who runs the site
    my application looks at has pointed out that my client should be
    checking the 'Last-Modified' header.

    I don't know if it is or not. Is it ? If not, how much of an
    HTTP client do I have to write to do this correctly ?

    If there's any doubt, I'm talking about the things discussed at

    [url]http://fishbowl.pastiche.org/archives/001132.html[/url]


    Simon Slavin Guest

  2. #2

    Default Re: Cocoa: does stringWithContentsOfURL do conditional GETs ?

    In article <BB82C24B96689DBA9810.0.1.2>,
    [email]slavinshearsay.demon.co.uk[/email]localhost (Simon Slavin) wrote:
    > I'm making use of stringWithContentsOfURL in a client which does
    > repeated downloading of an RSS feed (don't worry -- I don't
    > thrash the server). It's really useful and considerably
    > simplifies my application. However, the person who runs the site
    > my application looks at has pointed out that my client should be
    > checking the 'Last-Modified' header.
    >
    > I don't know if it is or not. Is it ? If not, how much of an
    > HTTP client do I have to write to do this correctly ?
    If you don't know if it is, then it's not. Think about it: You're
    passing an NSURL that you want loaded into the NSString. If you didn't
    tell the NSURL at some point what the last modified date is, there's no
    way it can know and therefore no way it can check.

    I'm not sure what the best solution is, although NSURL's
    -setProperty:ForKey looks mighty tempting. However you may need to
    consider using WebKit for this-- no need to write an HTTP client when
    Apple has already given you Safari's guts for free, eh?

    --
    Tom "Tom" Harrington
    Macaroni, Automated System Maintenance for Mac OS X.
    Version 1.4: Best cleanup yet, gets files other tools miss.
    See [url]http://www.atomicbird.com/[/url]
    Tom Harrington Guest

  3. #3

    Default Re: Cocoa: does stringWithContentsOfURL do conditional GETs ?

    In article <BB82C24B96689DBA9810.0.1.2>,
    [email]slavinshearsay.demon.co.uk[/email]localhost (Simon Slavin) wrote:
    > However, the person who runs the site
    > my application looks at has pointed out that my client should be
    > checking the 'Last-Modified' header.
    >
    > I don't know if it is or not. Is it ?
    No.
    > If not, how much of an
    > HTTP client do I have to write to do this correctly ?
    Depends on how you define "correctly". I don't know the internals of
    NSURL, but you can manually check the header with something like:

    NSString *remoteModString = [siteURL propertyForKey: "Last-Modified"];

    I do this for wCal, but I've never bothered to see if NSURL is smart
    enough to just get the headers to check that or if it's simply part of a
    full response. No mechamism for a proper, request-header-based
    conditional get seems to be supported. Look at the extensive set of
    other NSURL* classes or possibly Web* classes will help simplify the
    task.
    Doc O'Leary Guest

Similar Threads

  1. Visibility of Cocoa objects
    By Eric VERGNAUD in forum Mac Programming
    Replies: 6
    Last Post: September 13th, 07:34 PM
  2. Bit shifts in Cocoa
    By Korbin Meiser in forum Mac Programming
    Replies: 2
    Last Post: September 11th, 01:11 AM
  3. Q About Cocoa & CF Prefs..
    By David Phillip Oster in forum Mac Programming
    Replies: 2
    Last Post: July 31st, 12:04 PM
  4. Cocoa Filemaker
    By Olly Groves in forum FileMaker
    Replies: 2
    Last Post: July 25th, 01:55 AM
  5. [Cocoa] Bug with NSTableView?
    By Mark Bee in forum Mac Programming
    Replies: 1
    Last Post: July 7th, 07:38 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139