Firefox 3.5 sends HTTP OPTIONS with CPURLConnection

18 views
Skip to first unread message

Johannes Fahrenkrug

unread,
Sep 3, 2009, 10:09:19 AM9/3/09
to Cappuccino & Objective-J
Hi,

I'm working on a mid-sized Cappuccino app and it is pure joy to use
this wonderful framework. Thank you guys so much!

Everything works like a charm in Safari, but I'm having some trouble
with Firefox. I did disable the fileuri setting for local
development.
I'm making a CPURLConnection to get some JSON from a Rails app. When I
use it with Firefox, it sends the "OPTIONS" HTTP command (shows up in
both firebug and the rails log) although I explicitly set it to "GET".
That is weird. This is my code: http://gist.github.com/180314
I'm using the starter kit. Is this a known issue? Is there a way
around this?

Thanks so much!

- Johannes

Ross Boucher

unread,
Sep 3, 2009, 12:17:34 PM9/3/09
to objec...@googlegroups.com
Just a hunch, but you could try taking this line out:

[request setValue:"application/json"
forHTTPHeaderField:"Accept"];

I don't believe it's really necessary (though it's clearly not wrong,
and should work).

Johannes Fahrenkrug

unread,
Sep 3, 2009, 12:35:36 PM9/3/09
to Cappuccino & Objective-J
Hi Ross,

Thanks for the tip. I've tried that already and it didn't make a
difference... any more hunches ;-)?

- Johannes

Johannes Fahrenkrug

unread,
Sep 3, 2009, 12:51:43 PM9/3/09
to Cappuccino & Objective-J
Hi again,

very, very weird.... I changed @"GET" to @"POST" and it did a POST.
Good. Then I changed it to @"get" (small): And - Heureka! - it did a
GET request. Then I changed it back to @"GET" and it still worked.
Very strange. I cleared my Firefox cache and it still worked with the
capital GET. Maybe it was some weird Firefox caching issue... anyway,
it's working now. Move along, nothing to see here.

- Johannes

tim payton

unread,
Sep 6, 2009, 2:37:05 PM9/6/09
to Cappuccino & Objective-J
Hi Johannes...

I would be curious if you figured out any real cause... Because, I am
having the same inexplicable
error :)

Johannes Fahrenkrug

unread,
Sep 7, 2009, 10:27:33 AM9/7/09
to Cappuccino & Objective-J
Hi Tim,

unfortunately: No. I figured that it must have been some weird Firefox
caching bug. But I couldn't really pinpoint it. Did you try to change
it from "GET" to "get" or from "GET" to "POST"? What happens when you
do that?

It really is an extremely weird bug.

- Johannes

Ross Boucher

unread,
Sep 7, 2009, 12:21:53 PM9/7/09
to objec...@googlegroups.com
https://developer.mozilla.org/En/HTTP_access_control

This explains this new Firefox feature.

Ross Boucher

unread,
Sep 7, 2009, 12:21:59 PM9/7/09
to objec...@googlegroups.com
https://developer.mozilla.org/En/HTTP_access_control

This explains this new Firefox feature.

On Sep 7, 2009, at 10:27 AM, Johannes Fahrenkrug wrote:

>

Johannes Fahrenkrug

unread,
Sep 8, 2009, 1:59:57 AM9/8/09
to Cappuccino & Objective-J
Yes, this explains it indeed! Thank you, Ross.

tim payton

unread,
Sep 8, 2009, 7:43:22 AM9/8/09
to Cappuccino & Objective-J
Yes that explains the behavior :) I haven't been able to get rid of
the problem... I have tried changing the method to all the
variations.
Before I continue, I want to get my machine up and running with a
local apache server, and serve the cappuccino app like my server
will... so I can see whether this will really be a problem in
production :)

Thanks for the tips and insight.
Tim

tim payton

unread,
Sep 16, 2009, 3:58:13 PM9/16/09
to Cappuccino & Objective-J
Just as a solution...
I put both apps in the same apache virtual host. No more cross-site
problems.

If this isn't possible for you... try the suggestions in this article
(i haven't tried them, but seems like the right way)
http://cjedaudio.wordpress.com/2008/10/01/cappuccino-json-jsonp-cpjsonpconnection/

Enjoy :)
Tim

Holger Jahn

unread,
Sep 16, 2009, 6:35:22 PM9/16/09
to objec...@googlegroups.com
> https://developer.mozilla.org/En/HTTP_access_control
>
> This explains this new Firefox feature.

Correct, although the feature seems to have a bug I logged yesterday:

https://bugzilla.mozilla.org/show_bug.cgi?id=516927

Cross-domain access does not work if the CP app is running locally
("file://project/index.html), and the data source is remote
("http://domain.net/script). If this is the case, FF sends the
OPTIONS pre-flight check, but then never continues with GET/POST.
Reply all
Reply to author
Forward
0 new messages