2 Copyright (C) 2000-2004 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
6 OGo is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 #include "NGHttpRequest.h"
25 #include "NGUrlFormCoder.h"
27 NSString *methodNames[] = {
28 @"<unknown HTTP method>",
48 /* Exchange Ext Methods */
54 /* Exchange Bulk Methods */
63 @interface NGHttpMessage(PrivateMethods)
64 - (id)initWithHeader:(NGHashMap *)_header version:(NSString *)_version;
67 @implementation NGHttpRequest
69 - (id)initWithMethod:(NSString *)_methodName uri:(NSString *)_uri
70 header:(NGHashMap *)_header version:(NSString *)_version
72 if ((self = [super initWithHeader:_header version:_version])) {
73 self->method = NGHttpMethodFromString(_methodName);
74 self->uri = [_uri copyWithZone:[self zone]];
78 - (id)initWithHeader:(NGHashMap *)_header version:(NSString *)_version {
79 return [self initWithMethod:@"GET" uri:@"/" header:_header version:_version];
84 [self->uriParameters release];
90 - (NGHttpMethod)method {
93 - (NSString *)methodName {
94 return (self->method < NGHttpMethod_last) ? methodNames[self->method] : nil;
105 - (NGHashMap *)uriParameters { // parameters in x-www-form-urlencoded encoding
106 if (self->uriParameters == nil) {
107 const char *cstr = [self->uri cString];
108 const char *pos = index(cstr, '?');
112 self->uriParameters = NGDecodeUrlFormParameters(pos, strlen(pos));
115 return self->uriParameters;
120 - (BOOL)isDebuggingEnabled {
126 - (NSString *)description {
127 return [NSString stringWithFormat:
128 @"<HttpRequest: method=%@ uri=%@ header=%@ body=%@>",
135 @end /* NGHttpRequest */
137 NGHttpMethod NGHttpMethodFromString(NSString *_value) {
140 for (i = 1; i < NGHttpMethod_last; i++) {
141 NSString *name = methodNames[i];
143 if ([name isEqualToString:_value])