/* Copyright (C) 2000-2003 Max Berger This file is part of vCardReceiver, written for the OpenGroupware project (OGo) OGo is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. OGo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with OGo; see the file COPYING. If not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // $Id$ #include "URLPOSTRequestNGObjWeb.h" #include "NGObjWeb/NGObjWeb.h" @implementation URLPOSTRequest - (id)initWithURL:(NSURL *)_url { if ((self = [super init])) { self->url=nil; ASSIGN(self->url,_url); self->dataStore = nil; } return self; } - (void)dealloc { [self->url release]; [self->dataStore release]; [super dealloc]; } - (void)setPostData:(NSData *)_dataStore { ASSIGNCOPY(self->dataStore,_dataStore); } - (NSData *)data { return dataStore; } - (NSURL *)url { return url; } -(NSString *)valueForHTTPHeaderField:(NSString *)field { return @""; } @end /* URLPOSTRequest */ @implementation NSURLConnection + (NSData *)sendSynchronousRequest:(URLPOSTRequest *)request returningResponse:(NSURLResponse **)response error:(NSError **)error { WOHTTPConnection *conn = [[WOHTTPConnection alloc]initWithURL:[request url]]; WORequest *req = [[WORequest alloc]initWithMethod:@"POST" uri:[[request url]path] httpVersion:@"HTTP/1.1" headers:[[[NSDictionary alloc]init]autorelease] content:[request data] userInfo:[[[NSDictionary alloc]init]autorelease] ]; WOResponse *resp; [conn setKeepAliveEnabled:NO]; [conn sendRequest:req]; resp = [conn readResponse]; [req release]; [conn release]; *response = [[[NSURLResponse alloc]init]autorelease]; [*response setContentEncoding:[resp contentEncoding]]; *error = nil; if (resp == nil) *error = [[[NSError alloc]init]autorelease]; return [resp content]; } @end /* NSURLConnection */ @implementation NSURLResponse - (id)init { if ((self=[super init])) { self->contentEncoding=0; } return self; } - (NSString *)textEncodingName { return [NSString localizedNameOfStringEncoding:self->contentEncoding]; } - (void)setContentEncoding:(NSStringEncoding)_encoding; { self->contentEncoding = _encoding; } @end /* NSURLResponse */ @implementation NSError - (NSString*) description { return @"Could not connect to remote host"; } @end /* NSError */