2 Copyright (C) 2000-2005 SKYRIX Software AG
4 This file is part of SOPE.
6 SOPE 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 SOPE 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 SOPE; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #include "NGHttpRequest.h"
24 #include "NGUrlFormCoder.h"
26 NSString *methodNames[] = {
27 @"<unknown HTTP method>",
47 /* Exchange Ext Methods */
53 /* Exchange Bulk Methods */
62 @interface NGHttpMessage(PrivateMethods)
63 - (id)initWithHeader:(NGHashMap *)_header version:(NSString *)_version;
66 @implementation NGHttpRequest
68 - (id)initWithMethod:(NSString *)_methodName uri:(NSString *)_uri
69 header:(NGHashMap *)_header version:(NSString *)_version
71 if ((self = [super initWithHeader:_header version:_version])) {
72 self->method = NGHttpMethodFromString(_methodName);
73 self->uri = [_uri copyWithZone:[self zone]];
77 - (id)initWithHeader:(NGHashMap *)_header version:(NSString *)_version {
78 return [self initWithMethod:@"GET" uri:@"/" header:_header version:_version];
83 [self->uriParameters release];
89 - (NGHttpMethod)method {
92 - (NSString *)methodName {
93 return (self->method < NGHttpMethod_last) ? methodNames[self->method] : nil;
104 - (NGHashMap *)uriParameters { // parameters in x-www-form-urlencoded encoding
105 if (self->uriParameters == nil) {
106 const char *cstr = [self->uri cString];
107 const char *pos = index(cstr, '?');
111 self->uriParameters = NGDecodeUrlFormParameters(pos, strlen(pos));
114 return self->uriParameters;
119 - (BOOL)isDebuggingEnabled {
125 - (NSString *)description {
126 return [NSString stringWithFormat:
127 @"<HttpRequest: method=%@ uri=%@ header=%@ body=%@>",
134 @end /* NGHttpRequest */
136 NGHttpMethod NGHttpMethodFromString(NSString *_value) {
139 for (i = 1; i < NGHttpMethod_last; i++) {
140 NSString *name = methodNames[i];
142 if ([name isEqualToString:_value])