Overriding NSHTTPCookieStorage for WebView

  • Hello, I'm trying to make my own cookie storage system for WebView and
    to do that I've found that I need to override NSHTTPCookieStorage but
    when I do that how can I make webview use my overridden one?
    I've already wrote the cookie system, following the rules of cookie
    security and all, I just need to get this working...

    Thanks for the help,
    Mr. Gecko
  • Anybody at least knows how to use poseAsClass in 10.5, I think that's
    the problem.

    On Dec 28, 2008, at 7:52 PM, Mr. Gecko wrote:

    > Hello, I'm trying to make my own cookie storage system for WebView
    > and to do that I've found that I need to override
    > NSHTTPCookieStorage but when I do that how can I make webview use my
    > overridden one?
    > I've already wrote the cookie system, following the rules of cookie
    > security and all, I just need to get this working...
    >
    > Thanks for the help,
    > Mr. Gecko
  • Perhaps you could explain why you've felt the need to write a custom
    cookie storage system? I think it would help us figure the best
    solution. Bear in mind that NSHTTPCookieStorage's design is quite
    complicated in that it synchronises with all instances in other apps.

    Mike.

    On 29 Dec 2008, at 01:52, Mr. Gecko wrote:

    > Hello, I'm trying to make my own cookie storage system for WebView
    > and to do that I've found that I need to override
    > NSHTTPCookieStorage but when I do that how can I make webview use my
    > overridden one?
    > I've already wrote the cookie system, following the rules of cookie
    > security and all, I just need to get this working...
    >
    > Thanks for the help,
    > Mr. Gecko
  • Well I'm not wanting to use the default cookie system because I'm
    trying to make a secure browser which wont save the cookies and would
    reset the cookies if inactive and so on so forth.
    I did some more tests and tried to do poseAsClass in the main and I
    get this message in the debug output
    objc[87202]: MYHTTPCookieStorage: [MYHTTPCookieStorage
    poseAs:NSHTTPCookieStorage]: target not immediate superclass

    I don't know what that means, because I'm using NSObject as the
    superclass. Do I have to use NSHTTPCookieStorage as the superclass?
    This is how my main looks like.
    #import <Cocoa/Cocoa.h>
    #import "MYHTTPCookieStorage.h"

    int main(int argc, char *argv[])
    {
    [[MYHTTPCookieStorage class] poseAsClass:[NSHTTPCookieStorage class]];
        return NSApplicationMain(argc, (const char **) argv);
    }

    Thanks for the help,
    Mr. Gecko

    On Dec 29, 2008, at 10:57 AM, Mike Abdullah wrote:

    > Perhaps you could explain why you've felt the need to write a custom
    > cookie storage system? I think it would help us figure the best
    > solution. Bear in mind that NSHTTPCookieStorage's design is quite
    > complicated in that it synchronises with all instances in other apps.
    >
    > Mike.
    >
    > On 29 Dec 2008, at 01:52, Mr. Gecko wrote:
    >
    >> Hello, I'm trying to make my own cookie storage system for WebView
    >> and to do that I've found that I need to override
    >> NSHTTPCookieStorage but when I do that how can I make webview use
    >> my overridden one?
    >> I've already wrote the cookie system, following the rules of cookie
    >> security and all, I just need to get this working...
    >>
    >> Thanks for the help,
    >> Mr. Gecko
    >
  • when I change it from NSObject to NSHTTPCookieStorage it says this
    objc[87581]: MYHTTPCookieStorage: [MYHTTPCookieStorage
    poseAs:NSHTTPCookieStorage]: MYHTTPCookieStorage defines new instance
    variables

    On Dec 29, 2008, at 10:57 AM, Mike Abdullah wrote:

    > Perhaps you could explain why you've felt the need to write a custom
    > cookie storage system? I think it would help us figure the best
    > solution. Bear in mind that NSHTTPCookieStorage's design is quite
    > complicated in that it synchronises with all instances in other apps.
    >
    > Mike.
    >
    > On 29 Dec 2008, at 01:52, Mr. Gecko wrote:
    >
    >> Hello, I'm trying to make my own cookie storage system for WebView
    >> and to do that I've found that I need to override
    >> NSHTTPCookieStorage but when I do that how can I make webview use
    >> my overridden one?
    >> I've already wrote the cookie system, following the rules of cookie
    >> security and all, I just need to get this working...
    >>
    >> Thanks for the help,
    >> Mr. Gecko
    >
  • You need to look more closely at the docs for +poseAs:.

    --Andy

    On Dec 29, 2008, at 12:19 PM, Mr. Gecko wrote:

    > when I change it from NSObject to NSHTTPCookieStorage it says this
    > objc[87581]: MYHTTPCookieStorage: [MYHTTPCookieStorage
    > poseAs:NSHTTPCookieStorage]: MYHTTPCookieStorage defines new
    > instance variables
    >
    > On Dec 29, 2008, at 10:57 AM, Mike Abdullah wrote:
    >
    >> Perhaps you could explain why you've felt the need to write a
    >> custom cookie storage system? I think it would help us figure the
    >> best solution. Bear in mind that NSHTTPCookieStorage's design is
    >> quite complicated in that it synchronises with all instances in
    >> other apps.
    >>
    >> Mike.
    >>
    >> On 29 Dec 2008, at 01:52, Mr. Gecko wrote:
    >>
    >>> Hello, I'm trying to make my own cookie storage system for WebView
    >>> and to do that I've found that I need to override
    >>> NSHTTPCookieStorage but when I do that how can I make webview use
    >>> my overridden one?
    >>> I've already wrote the cookie system, following the rules of
    >>> cookie security and all, I just need to get this working...
    >>>
    >>> Thanks for the help,
    >>> Mr. Gecko
    >>

  • Ok I finally got it together, the problem I'm having now is that
    WebView calls [NSHTTPCookieStorage(NSPrivate) _cookieStorage] and than
    goes to debugger.
    I know it works because I tried NSLog(@"%@", [[NSHTTPCookieStorage
    sharedHTTPCookieStorage] cookies]); and it outputs an empty array like
    I had it to. and when I add a cookie it outputs that cookie in the
    array.

    On Dec 29, 2008, at 1:39 PM, Andy Lee wrote:

    > You need to look more closely at the docs for +poseAs:.
    >
    > --Andy
    >
    > On Dec 29, 2008, at 12:19 PM, Mr. Gecko wrote:
    >
    >> when I change it from NSObject to NSHTTPCookieStorage it says this
    >> objc[87581]: MYHTTPCookieStorage: [MYHTTPCookieStorage
    >> poseAs:NSHTTPCookieStorage]: MYHTTPCookieStorage defines new
    >> instance variables
    >>
    >> On Dec 29, 2008, at 10:57 AM, Mike Abdullah wrote:
    >>
    >>> Perhaps you could explain why you've felt the need to write a
    >>> custom cookie storage system? I think it would help us figure the
    >>> best solution. Bear in mind that NSHTTPCookieStorage's design is
    >>> quite complicated in that it synchronises with all instances in
    >>> other apps.
    >>>
    >>> Mike.
    >>>
    >>> On 29 Dec 2008, at 01:52, Mr. Gecko wrote:
    >>>
    >>>> Hello, I'm trying to make my own cookie storage system for
    >>>> WebView and to do that I've found that I need to override
    >>>> NSHTTPCookieStorage but when I do that how can I make webview use
    >>>> my overridden one?
    >>>> I've already wrote the cookie system, following the rules of
    >>>> cookie security and all, I just need to get this working...
    >>>>
    >>>> Thanks for the help,
    >>>> Mr. Gecko
    >>>

    >
  • The system really isn't designed for this sort of thing sadly :( How
    about instead, setting up a WebResourceLoadDelegate to modify all
    outgoing URL requests doing:

    [aRequest setHTTPShouldHandleCookies:NO]

    You can then again use the WebResourceLoadDelegate methods to receive
    the URL response and handle the cookie from it as you'd like.

    Mike.

    On 29 Dec 2008, at 17:17, Mr. Gecko wrote:

    > Well I'm not wanting to use the default cookie system because I'm
    > trying to make a secure browser which wont save the cookies and
    > would reset the cookies if inactive and so on so forth.
    > I did some more tests and tried to do poseAsClass in the main and I
    > get this message in the debug output
    > objc[87202]: MYHTTPCookieStorage: [MYHTTPCookieStorage
    > poseAs:NSHTTPCookieStorage]: target not immediate superclass
    >
    > I don't know what that means, because I'm using NSObject as the
    > superclass. Do I have to use NSHTTPCookieStorage as the superclass?
    > This is how my main looks like.
    > #import <Cocoa/Cocoa.h>
    > #import "MYHTTPCookieStorage.h"
    >
    > int main(int argc, char *argv[])
    > {
    > [[MYHTTPCookieStorage class] poseAsClass:[NSHTTPCookieStorage
    > class]];
    > return NSApplicationMain(argc, (const char **) argv);
    > }
    >
    > Thanks for the help,
    > Mr. Gecko
    >
    > On Dec 29, 2008, at 10:57 AM, Mike Abdullah wrote:
    >
    >> Perhaps you could explain why you've felt the need to write a
    >> custom cookie storage system? I think it would help us figure the
    >> best solution. Bear in mind that NSHTTPCookieStorage's design is
    >> quite complicated in that it synchronises with all instances in
    >> other apps.
    >>
    >> Mike.
    >>
    >> On 29 Dec 2008, at 01:52, Mr. Gecko wrote:
    >>
    >>> Hello, I'm trying to make my own cookie storage system for WebView
    >>> and to do that I've found that I need to override
    >>> NSHTTPCookieStorage but when I do that how can I make webview use
    >>> my overridden one?
    >>> I've already wrote the cookie system, following the rules of
    >>> cookie security and all, I just need to get this working...
    >>>
    >>> Thanks for the help,
    >>> Mr. Gecko
    >>
    >
  • so your saying to make it set up the cookies headers for the
    NSURLRequest?
    if I do that, how can I get the setcookie header from the server?

    On Dec 29, 2008, at 5:25 PM, Mike Abdullah wrote:

    > The system really isn't designed for this sort of thing sadly :( How
    > about instead, setting up a WebResourceLoadDelegate to modify all
    > outgoing URL requests doing:
    >
    > [aRequest setHTTPShouldHandleCookies:NO]
    >
    > You can then again use the WebResourceLoadDelegate methods to
    > receive the URL response and handle the cookie from it as you'd like.
    >
    > Mike.
    >
    > On 29 Dec 2008, at 17:17, Mr. Gecko wrote:
    >
    >> Well I'm not wanting to use the default cookie system because I'm
    >> trying to make a secure browser which wont save the cookies and
    >> would reset the cookies if inactive and so on so forth.
    >> I did some more tests and tried to do poseAsClass in the main and I
    >> get this message in the debug output
    >> objc[87202]: MYHTTPCookieStorage: [MYHTTPCookieStorage
    >> poseAs:NSHTTPCookieStorage]: target not immediate superclass
    >>
    >> I don't know what that means, because I'm using NSObject as the
    >> superclass. Do I have to use NSHTTPCookieStorage as the superclass?
    >> This is how my main looks like.
    >> #import <Cocoa/Cocoa.h>
    >> #import "MYHTTPCookieStorage.h"
    >>
    >> int main(int argc, char *argv[])
    >> {
    >> [[MYHTTPCookieStorage class] poseAsClass:[NSHTTPCookieStorage
    >> class]];
    >> return NSApplicationMain(argc, (const char **) argv);
    >> }
    >>
    >> Thanks for the help,
    >> Mr. Gecko
    >>
    >> On Dec 29, 2008, at 10:57 AM, Mike Abdullah wrote:
    >>
    >>> Perhaps you could explain why you've felt the need to write a
    >>> custom cookie storage system? I think it would help us figure the
    >>> best solution. Bear in mind that NSHTTPCookieStorage's design is
    >>> quite complicated in that it synchronises with all instances in
    >>> other apps.
    >>>
    >>> Mike.
    >>>
    >>> On 29 Dec 2008, at 01:52, Mr. Gecko wrote:
    >>>
    >>>> Hello, I'm trying to make my own cookie storage system for
    >>>> WebView and to do that I've found that I need to override
    >>>> NSHTTPCookieStorage but when I do that how can I make webview use
    >>>> my overridden one?
    >>>> I've already wrote the cookie system, following the rules of
    >>>> cookie security and all, I just need to get this working...
    >>>>
    >>>> Thanks for the help,
    >>>> Mr. Gecko
    >>>
    >>
    >
  • I'm going to try and use the WebKit source to make it do what I need
    it to do.

    On Dec 29, 2008, at 6:46 PM, Mike Abdullah wrote:

    > The WebResourceLoadDelegate will notify you when it receives a URL
    > response. That response should be of the NSHTTPURLResponse class and
    > the -allHeaderFields method should allow you to access its setcookie
    > header. You can choose to do what you like with that header,
    > presumably placing it into your cookie storage.
    >
    > On 29 Dec 2008, at 23:28, Mr. Gecko wrote:
    >
    >> so your saying to make it set up the cookies headers for the
    >> NSURLRequest?
    >> if I do that, how can I get the setcookie header from the server?
    >>
    >> On Dec 29, 2008, at 5:25 PM, Mike Abdullah wrote:
    >>
    >>> The system really isn't designed for this sort of thing sadly :
    >>> ( How about instead, setting up a WebResourceLoadDelegate to
    >>> modify all outgoing URL requests doing:
    >>>
    >>> [aRequest setHTTPShouldHandleCookies:NO]
    >>>
    >>> You can then again use the WebResourceLoadDelegate methods to
    >>> receive the URL response and handle the cookie from it as you'd
    >>> like.
    >>>
    >>> Mike.
    >>>
    >>> On 29 Dec 2008, at 17:17, Mr. Gecko wrote:
    >>>
    >>>> Well I'm not wanting to use the default cookie system because I'm
    >>>> trying to make a secure browser which wont save the cookies and
    >>>> would reset the cookies if inactive and so on so forth.
    >>>> I did some more tests and tried to do poseAsClass in the main and
    >>>> I get this message in the debug output
    >>>> objc[87202]: MYHTTPCookieStorage: [MYHTTPCookieStorage
    >>>> poseAs:NSHTTPCookieStorage]: target not immediate superclass
    >>>>
    >>>> I don't know what that means, because I'm using NSObject as the
    >>>> superclass. Do I have to use NSHTTPCookieStorage as the superclass?
    >>>> This is how my main looks like.
    >>>> #import <Cocoa/Cocoa.h>
    >>>> #import "MYHTTPCookieStorage.h"
    >>>>
    >>>> int main(int argc, char *argv[])
    >>>> {
    >>>> [[MYHTTPCookieStorage class] poseAsClass:[NSHTTPCookieStorage
    >>>> class]];
    >>>> return NSApplicationMain(argc, (const char **) argv);
    >>>> }
    >>>>
    >>>> Thanks for the help,
    >>>> Mr. Gecko
    >>>>
    >>>> On Dec 29, 2008, at 10:57 AM, Mike Abdullah wrote:
    >>>>
    >>>>> Perhaps you could explain why you've felt the need to write a
    >>>>> custom cookie storage system? I think it would help us figure
    >>>>> the best solution. Bear in mind that NSHTTPCookieStorage's
    >>>>> design is quite complicated in that it synchronises with all
    >>>>> instances in other apps.
    >>>>>
    >>>>> Mike.
    >>>>>
    >>>>> On 29 Dec 2008, at 01:52, Mr. Gecko wrote:
    >>>>>
    >>>>>> Hello, I'm trying to make my own cookie storage system for
    >>>>>> WebView and to do that I've found that I need to override
    >>>>>> NSHTTPCookieStorage but when I do that how can I make webview
    >>>>>> use my overridden one?
    >>>>>> I've already wrote the cookie system, following the rules of
    >>>>>> cookie security and all, I just need to get this working...
    >>>>>>
    >>>>>> Thanks for the help,
    >>>>>> Mr. Gecko
    >>>>>
    >>>>
    >>>
    >>
    >
  • On Dec 30, 2008, at 11:05 AM, Mr. Gecko wrote:

    > I'm going to try and use the WebKit source to make it do what I need
    > it to do.
    >

    That's a bad idea, unless you like rewriting your code for
    (potentially) every OS update, having a large test matrix that allows
    you to test against multiple "dot releases" (and various "security
    updates", not to mention potential Safari public betas, etc...),
    refactor your code to be able to support multiple SPI/code paths (such
    as by having all that code factored off into a loadable bundle which
    is loaded based on WebKit version), and dealing with customers that
    complain that your app stops works correctly "for no reason" (other
    than the fact that they applied a security update).  After all, WebKit
    is probably updated more than any other single OS component...

    Just because the source for WebKit is available does not make any of
    those private APIs public.

    Glenn Andreas                      <gandreas...>
    The most merciful thing in the world ... is the inability of the human
    mind to correlate all its contents - HPL
  • Ok, Thanks for telling me, I'll just read how it does the cookies and
    than make my private cookie system work with what they do.

    On Dec 30, 2008, at 11:14 AM, glenn andreas wrote:

    >
    > On Dec 30, 2008, at 11:05 AM, Mr. Gecko wrote:
    >
    >> I'm going to try and use the WebKit source to make it do what I
    >> need it to do.
    >>
    >
    > That's a bad idea, unless you like rewriting your code for
    > (potentially) every OS update, having a large test matrix that
    > allows you to test against multiple "dot releases" (and various
    > "security updates", not to mention potential Safari public betas,
    > etc...), refactor your code to be able to support multiple SPI/code
    > paths (such as by having all that code factored off into a loadable
    > bundle which is loaded based on WebKit version), and dealing with
    > customers that complain that your app stops works correctly "for no
    > reason" (other than the fact that they applied a security update).
    > After all, WebKit is probably updated more than any other single OS
    > component...
    >
    > Just because the source for WebKit is available does not make any of
    > those private APIs public.
    >
    > Glenn Andreas                      <gandreas...>
    > The most merciful thing in the world ... is the inability of the
    > human mind to correlate all its contents - HPL
    >
previous month december 2008 next month
MTWTFSS
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        
Go to today