Cocoa: does stringWithContentsOfURL do conditional GETs ?

Ask a Question related to Mac Programming, Design and Development.

  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. Similar Questions and Discussions

    1. Cocoa: NSComboBoxCell in NSTableColumn
      Hi, my application uses a NSTableView with one NSTableColumn, which needs a combobox instead of a texfield as the data-cell. Creating a...
    2. Bit shifts in Cocoa
      Does anyone know how to do bit shifts in Cocoa? I have declared an integer and I want to shift it one bit to the right (same as dividing by 2). ...
    3. Q About Cocoa & CF Prefs..
      In article <no-EA814A.20172229072003@netnews.upenn.edu>, Mark Haase <no@spam.please> wrote: Not only that, if the same preference file is...
    4. Cocoa Filemaker
      "Edward Smith" <esmith@thegoodstuff.se> wrote in message news:BB44ABA1.4676%esmith@thegoodstuff.se... I presume so. There was a statement from...
    5. [Cocoa] Bug with NSTableView?
      > I'll check these accessor methods, as this may be the problem. It was the setCol* methods that were causing the problem. I stupidly put:...
  3. #2

    Default Re: Cocoa: does stringWithContentsOfURL do conditional GETs ?

    In article <BB82C24B96689DBA98@10.0.1.2>,
    [email]slavins@hearsay.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

  4. #3

    Default Re: Cocoa: does stringWithContentsOfURL do conditional GETs ?

    In article <BB82C24B96689DBA98@10.0.1.2>,
    [email]slavins@hearsay.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

Posting Permissions

  • You may not post new threads
  • You may 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