Hi,

Thank you for the great tip...

I tried curl and gotten "500 Internal Server Error-The server encountered an internal error or misconfiguration and was unable to complete your request." But how can I troubleshoot this one? My ISP is sure going to come back to me with "It works in our server, so there is NO error!".

Is this a bug with Cocoa?

Thank you in advance...

James
On 2009/10/23, at 上午2:11, John Horigan wrote:

Try using curl (the command-line utility) to see _exactly_ what Cocoa gets from the server when it accesses that URL. The server could be doing something that confuses Cocoa but which PHP and Safari handle properly.

-- john

On Oct 22, 2009, at 8:52 AM, Jens Alfke wrote:


On Oct 22, 2009, at 7:16 AM, James Lin wrote:

NSString *result = [NSString stringWithContentsOfURL:theURL encoding:NSUTF8StringEncoding error:&error];
However, the result comes back with an NSError as the following:
Error Domain=NSCocoaErrorDomain Code=256 UserInfo=0x15d7b0 "Operation could not be completed. (Cocoa error 256.)
which is a NSFileReadUnknownError = 256.
BUT! The same URL string works perfectly in a Safari window and the PHP script executes fine when accessed from Safari...

That's a weird error I haven't seen before — looks like a generic "duh, something went wrong" fallback.

My first guess is that NSString can't decode the URL response into a string due to encoding issues; maybe the content uses an encoding that's incompatible with UTF-8? I would start trying lower-level calls to find the point where it starts to work.
-[NSString stringWithContentsOfURL:usedEncoding:error:]
-[NSData dataWithContentsOfURL:...]
-[NSURLConnection sendSynchronousRequest:...]

Note that in most cases you don't want to use this type of synchronous call on a remote URL because it blocks the thread for an arbitrary amount of time. The usual Cocoa style is to use an asynchronous request via NSURLRequest.

—Jens_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/john%40glyphic.com

This email sent to j...@glyphic.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/jamesclin827%40gmail.com

This email sent to jamesclin...@gmail.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to