@end
/* }}} */
-/* Cydget-PHP:// Protocol {{{ */
-@interface CydgetPHPURLProtocol : NSURLProtocol {
+/* Cydget-CGI:// Protocol {{{ */
+@interface CydgetCGIURLProtocol : NSURLProtocol {
pid_t pid_;
CFHTTPMessageRef http_;
NSFileHandle *handle_;
@end
-@implementation CydgetPHPURLProtocol
+@implementation CydgetCGIURLProtocol
+ (BOOL) canInitWithRequest:(NSURLRequest *)request {
NSURL *url([request URL]);
if (url == nil)
return NO;
NSString *scheme([[url scheme] lowercaseString]);
- if (scheme == nil || ![scheme isEqualToString:@"cydget-php"])
+ if (scheme == nil || ![scheme isEqualToString:@"cydget-cgi"])
return NO;
return YES;
}
NSURL *url([request URL]);
NSString *path([url path]);
- if (path == nil || ![path hasSuffix:@".php"]) {
+ if (path == nil) {
[client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorResourceUnavailable userInfo:nil]];
return;
}
}
if (pid_ == 0) {
+ const char *script([path UTF8String]);
+
setenv("GATEWAY_INTERFACE", "CGI/1.1", true);
- setenv("SCRIPT_FILENAME", [path UTF8String], true);
+ setenv("SCRIPT_FILENAME", script, true);
NSString *query([url query]);
if (query != nil)
setenv("QUERY_STRING", [query UTF8String], true);
_assert(close(fds[0]) != -1);
_assert(close(fds[1]) != -1);
- execl("/usr/bin/php-cgi", "php-cgi", NULL);
+ execl(script, script, NULL);
exit(1);
_assert(false);
}
//[client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorNetworkConnectionLost userInfo:nil]];
-- (void) stopLoading {
+- (void) stopLoading_ {
[[NSNotificationCenter defaultCenter] removeObserver:self];
- [handle_ release];
- handle_ = nil;
+
+ if (handle_ != nil) {
+ [handle_ release];
+ handle_ = nil;
+ }
if (pid_ != -1) {
kill(pid_, SIGTERM);
}
}
+- (void) stopLoading {
+ [self
+ performSelectorOnMainThread:@selector(stopLoading_)
+ withObject:nil
+ waitUntilDone:NO
+ ];
+}
+
@end
/* }}} */
apr_initialize();
[NSURLProtocol registerClass:[CydgetURLProtocol class]];
- [NSURLProtocol registerClass:[CydgetPHPURLProtocol class]];
+ [NSURLProtocol registerClass:[CydgetCGIURLProtocol class]];
void (*_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE)(JSC::SourceCode **, JSC::JSGlobalData *, int *, JSC::UString *);
dlset(_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, "_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE");