Ok, I've found the source of the problem and a work-around. The status
code 0 originates in HTTPConnection.m:1174:
// Default status code: 200 - OK
NSInteger status = 200;
if ([httpResponse respondsToSelector:@selector(status)])
{
status = [httpResponse status];
}
Debugger output at this point:
(lldb) po httpResponse
2012-05-04 11:37:04.147 App[9404:707] >>>>>> 1 docs being updated
(NSObject *) $5 = 0x1de81b20 Response[GET /app_test/_local/
bfca65ed062d9d28d05dd2e37eceda78c31e7914]
(lldb) po [httpResponse status]
(id) $6 = 0x00000000 <nil>
What's interesting is that httpResponse is of NSObject, not
TDResponse. If I read this correctly, it's a response that
CocoaHTTPServer generates, not one that comes from your override in
[TDHTTPConnection httpResponseForMethod:URI:].
When I assume that the "true" default of status should be 200 and
therefore change HTTPConnection accordingly, like so:
if ([httpResponse respondsToSelector:@selector(status)] &&
[httpResponse status] != 0)
{
status = [httpResponse status];
}
I find that replication works for me :)
I'm still puzzled why it works for Nico but not me. My CocoaHTTPServer
version is 37a78143ac3401e1f2da6973bbdf8e79ca9db742 (Wed Apr 25).
I'll ask Robbie Hanson if this could be a bug in CocoaHTTPServer.
Cheers,
Sven