1 // $Id: WORequest+Apache.m,v 1.1 2004/06/08 11:06:00 helge Exp $
3 #include "WORequest+Apache.h"
4 #include <ApacheAPI/ApacheRequest.h>
5 #include <ApacheAPI/ApacheTable.h>
6 #include <ApacheAPI/ApacheConnection.h>
9 @interface WORequest(ApachePrivates)
11 - (NSData *)readDataFromApacheRequest:(ApacheRequest *)_rq;
15 @implementation WORequest(Apache)
17 - (id)initWithApacheRequest:(ApacheRequest *)_rq {
18 NSMutableDictionary *headers;
19 NSAutoreleasePool *pool;
20 NSString *httpVersion = nil;
30 pool = [[NSAutoreleasePool alloc] init];
31 headers = [[NSMutableDictionary alloc] initWithCapacity:32];
33 /* the values need to be parsed ! */
39 hin = [_rq headersIn];
40 keys = [hin keyEnumerator];
41 while ((key = [keys nextObject])) {
44 if ((value = [hin objectForKey:key]) == nil) {
45 [self logWithFormat:@"got no value for key '%@' ..", key];
49 /* NGObjWeb expects all keys to be lowercase .. */
50 key = [key lowercaseString];
51 [headers setObject:value forKey:key];
55 /* setup "special" headers */
57 ApacheConnection *con = [_rq connection];
60 if ((tmp = [headers objectForKey:@"host"])) {
61 tmp = [@"http://" stringByAppendingString:tmp];
62 [headers setObject:tmp forKey:@"x-webobjects-server-url"];
64 if ([(tmp = [con remoteHost]) length] > 0)
65 [headers setObject:tmp forKey:@"x-webobjects-remote-host"];
66 if ([(tmp = [con user]) length] > 0)
67 [headers setObject:tmp forKey:@"x-webobjects-remote-user"];
68 if ([(tmp = [con authorizationType]) length] > 0)
69 [headers setObject:tmp forKey:@"x-webobjects-auth-type"];
72 /* content, this is to be done ... (libapr ?, hm) */
73 contentData = [self readDataFromApacheRequest:_rq];
77 ui = [NSDictionary dictionaryWithObject:_rq forKey:@"ApacheRequest"];
82 const char *cstr = [[_rq unparsedURI] cString];
83 const char *pos = index(cstr, '?');
87 form = NGDecodeUrlFormParameters(pos, strlen(pos));
95 self = [self initWithMethod:[_rq method]
97 httpVersion:httpVersion
101 ASSIGN(self->formContent, form);
108 - (NSData *)readDataFromApacheRequest:(ApacheRequest *)_rq {
109 #warning read request content if available ...
113 - (ApacheRequest *)apacheRequest {
114 return [[self userInfo] objectForKey:@"ApacheRequest"];
117 @end /* WORequest(Apache) */