Code: Select all
if( response_code != 200 )
{
tr_snprintf( result, sizeof( result ), "portTested: http error %ld: %s",
response_code, tr_webGetResponseStr( response_code ) );
}
else /* success */
{
const bool isOpen = response_byte_count && *(char*)response == '1';
tr_bencDictAddBool( data->args_out, "port-is-open", isOpen );
tr_snprintf( result, sizeof( result ), "success" );
}
for Mac:
Code: Select all
@implementation PortChecker (Private)
- (void) startProbe: (NSTimer *) timer
{
[fTimer release];
fTimer = nil;
NSURLRequest * portProbeRequest = [NSURLRequest requestWithURL: [NSURL URLWithString: CHECKER_URL([[timer userInfo] integerValue])]
cachePolicy: NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval: 15.0];
if ((fConnection = [[NSURLConnection alloc] initWithRequest: portProbeRequest delegate: self]))
fPortProbeData = [[NSMutableData alloc] init];
else
{
NSLog(@"Unable to get port status: failed to initiate connection");
[self callBackWithStatus: PORT_STATUS_ERROR];
}
}
- (void) callBackWithStatus: (port_status_t) status
{
fStatus = status;
if (fDelegate && [fDelegate respondsToSelector: @selector(portCheckerDidFinishProbing:)])
[fDelegate performSelectorOnMainThread: @selector(portCheckerDidFinishProbing:) withObject: self waitUntilDone: NO];
}
@end
Initiating server query ...
Looking up IP address for domain: forum.transmissionbt.com
The IP address for the domain is: 91.121.60.42
Connecting to the server on standard HTTP port: 80
[Connected] Requesting the server's default page.
The server returned the following response headers:
HTTP/1.1 301 Moved Permanently
Location: https://forum.transmissionbt.com/
Content-Length: 0
Connection: close
Date: Sat, 29 Dec 2012 17:44:25 GMT
Server: lighttpd/1.4.28
Query complete.
Good the ABOVE looks OK
BAD! --> HTTP/1.1 400 Bad Request
don't look right?
Initiating server query ...
Looking up IP address for domain: portcheck.transmissionbt.com
The IP address for the domain is: 91.121.60.42
Connecting to the server on standard HTTP port: 80
[Connected] Requesting the server's default page.
The server returned the following response headers:
HTTP/1.1 400 Bad Request
Connection: close
Transfer-Encoding: chunked
Date: Sat, 29 Dec 2012 17:46:29 GMT
Server: lighttpd/1.4.28
Query complete.