2 Copyright (C) 2000-2004 SKYRIX Software AG
4 This file is part of OGo
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
24 #include "OGoComponent.h"
25 #include <Foundation/Foundation.h>
26 #include <NGObjWeb/NGObjWeb.h>
27 #include <NGExtensions/NGExtensions.h>
30 @interface OGoComponent (PrivateAPI)
31 - (void)_parseQueryString:(NSString *)_s;
35 @implementation OGoComponent
38 if ((self = [super init])) {
39 self->queryParameters = [[NSMutableDictionary alloc] init];
45 [self->queryParameters release];
57 req = [[self context] request];
59 r = [uri rangeOfString:@"?"];
63 qs = [uri substringFromIndex:(r.location + r.length)];
64 [self->queryParameters removeAllObjects];
65 [self _parseQueryString:qs];
69 - (void)_parseQueryString:(NSString *)_s {
73 e = [[_s componentsSeparatedByString:@"&"] objectEnumerator];
74 while ((part = [e nextObject])) {
76 NSString *key, *value;
78 r = [part rangeOfString:@"="];
80 /* missing value of query parameter */
81 key = [part stringByUnescapingURL];
85 key = [[part substringToIndex:r.location] stringByUnescapingURL];
86 value = [[part substringFromIndex:(r.location + r.length)]
87 stringByUnescapingURL];
89 [self->queryParameters setObject:value forKey:key];
93 - (NSString *)queryParameterForKey:(NSString *)_key {
94 return [self->queryParameters objectForKey:_key];
97 - (void)setQueryParameter:(NSString *)_param forKey:(NSString *)_key {
102 [self->queryParameters setObject:_param forKey:_key];
104 [self->queryParameters removeObjectForKey:_key];
107 - (NSDictionary *)queryParameters {
108 return self->queryParameters;
111 - (NSString *)completeHrefForMethod:(NSString *)_method {
115 qp = [self queryParameters];
119 qs = [[self context] queryStringFromDictionary:qp];
120 return [_method stringByAppendingFormat:@"?%@", qs];