Author: rfm
Date: Tue Jul 1 14:06:54 2014
New Revision: 37972
URL: http://svn.gna.org/viewcvs/gnustep?rev=37972&view=rev
Log:
Allow content type to be specified
Modified:
libs/webservices/trunk/ChangeLog
libs/webservices/trunk/GNUmakefile
libs/webservices/trunk/GWSPrivate.h
libs/webservices/trunk/GWSService.h
libs/webservices/trunk/GWSService.m
Modified: libs/webservices/trunk/ChangeLog
URL:
http://svn.gna.org/viewcvs/gnustep/libs/webservices/trunk/ChangeLog?rev=37972&r1=37971&r2=37972&view=diff
==============================================================================
--- libs/webservices/trunk/ChangeLog (original)
+++ libs/webservices/trunk/ChangeLog Tue Jul 1 14:06:54 2014
@@ -1,3 +1,15 @@
+2014-07-01 Richard Frith-Macdonald <[email protected]>
+
+ * GWSService.h:
+ * GWSService.m:
+ Allow content type of request to be controlled.
+ * GNUmakefile: bump version for release
+ Version 0.6.4: bugfix release.
+
+2014-06-23 Richard Frith-Macdonald <[email protected]>
+
+ * GWSService.m: Ensure that timer is cancelled when I/O is complete.
+
2014-06-04 Richard Frith-Macdonald <[email protected]>
* GNUmakefile: bump version for release
Modified: libs/webservices/trunk/GNUmakefile
URL:
http://svn.gna.org/viewcvs/gnustep/libs/webservices/trunk/GNUmakefile?rev=37972&r1=37971&r2=37972&view=diff
==============================================================================
--- libs/webservices/trunk/GNUmakefile (original)
+++ libs/webservices/trunk/GNUmakefile Tue Jul 1 14:06:54 2014
@@ -21,7 +21,7 @@
-include config.make
PACKAGE_NAME = WebServices
-PACKAGE_VERSION = 0.6.3
+PACKAGE_VERSION = 0.6.4
WebServices_INTERFACE_VERSION=0.6
CVS_MODULE_NAME = gnustep/dev-libs/WebServices
CVS_TAG_NAME = WebServices
Modified: libs/webservices/trunk/GWSPrivate.h
URL:
http://svn.gna.org/viewcvs/gnustep/libs/webservices/trunk/GWSPrivate.h?rev=37972&r1=37971&r2=37972&view=diff
==============================================================================
--- libs/webservices/trunk/GWSPrivate.h (original)
+++ libs/webservices/trunk/GWSPrivate.h Tue Jul 1 14:06:54 2014
@@ -77,6 +77,7 @@
- (void) _activate;
- (void) _clean;
- (void) _completed;
+- (void) _completedIO;
- (BOOL) _enqueue;
- (id) _initWithName: (NSString*)name document: (GWSDocument*)document;
- (void) _received;
Modified: libs/webservices/trunk/GWSService.h
URL:
http://svn.gna.org/viewcvs/gnustep/libs/webservices/trunk/GWSService.h?rev=37972&r1=37971&r2=37972&view=diff
==============================================================================
--- libs/webservices/trunk/GWSService.h (original)
+++ libs/webservices/trunk/GWSService.h Tue Jul 1 14:06:54 2014
@@ -136,6 +136,7 @@
RPCActive, // In the I/O thread
RPCParsing // Parsing the response data
} _stage;
+ NSString *_contentType;
}
/** Returns a description of the current asynchronous service queues.
@@ -316,6 +317,12 @@
* different delegate.
*/
- (void) setCoder: (GWSCoder*)aCoder;
+
+/**
+ * Sets the value of the Content-Type header to be sent with a request.<br />
+ * Setting a nil or empty string value reverts to the default of text/xml.
+ */
+- (void) setContentType: (NSString*)cType;
/** Specifies whether debug information is enabled. See -debug for more
* information.
Modified: libs/webservices/trunk/GWSService.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/webservices/trunk/GWSService.m?rev=37972&r1=37971&r2=37972&view=diff
==============================================================================
--- libs/webservices/trunk/GWSService.m (original)
+++ libs/webservices/trunk/GWSService.m Tue Jul 1 14:06:54 2014
@@ -489,6 +489,18 @@
[_delegate completedRPC: self];
}
}
+}
+
+- (void) _completedIO
+{
+ /* Must be called in locked region and when _ioThread is not nil!
+ * Once I/O has been completed, we can't time out ... the RPC has
+ * either failed or succeeded.
+ */
+ _completedIO = YES;
+ threadRem(&_ioThread);
+ [_timer invalidate];
+ _timer = nil;
}
- (BOOL) _enqueue
@@ -902,7 +914,14 @@
[request setCachePolicy: NSURLRequestReloadIgnoringCacheData];
[request setHTTPMethod: @"POST"];
[request setValue: @"GWSService/0.1.0" forHTTPHeaderField:
@"User-Agent"];
- [request setValue: @"text/xml" forHTTPHeaderField: @"Content-Type"];
+ if (nil == _contentType)
+ {
+ [request setValue: @"text/xml" forHTTPHeaderField: @"Content-Type"];
+ }
+ else
+ {
+ [request setValue: _contentType forHTTPHeaderField: @"Content-Type"];
+ }
if (_SOAPAction != nil)
{
[request setValue: _SOAPAction forHTTPHeaderField: @"SOAPAction"];
@@ -964,7 +983,14 @@
[handle addClient: (id<NSURLHandleClient>)self];
[handle writeProperty: @"POST" forKey: GSHTTPPropertyMethodKey];
[handle writeProperty: @"GWSService/0.1.0" forKey: @"User-Agent"];
- [handle writeProperty: @"text/xml" forKey: @"Content-Type"];
+ if (nil == _contentType)
+ {
+ [handle writeProperty: @"text/xml" forKey: @"Content-Type"];
+ }
+ else
+ {
+ [handle writeProperty: _contentType forKey: @"Content-Type"];
+ }
if ([_headers count] > 0)
{
NSEnumerator *e = [_headers keyEnumerator];
@@ -1571,6 +1597,21 @@
_compact = flag;
}
+- (void) setContentType: (NSString*)cType
+{
+ if ([cType length] == 0)
+ {
+ cType = nil;
+ }
+ if (NO == [_contentType isEqual: cType])
+ {
+ NSString *old = _contentType;
+
+ _contentType = [cType copy];
+ [old release];
+ }
+}
+
- (void) setDebug: (BOOL)flag
{
_debug = flag;
@@ -1619,7 +1660,7 @@
- (void) setSOAPAction: (NSString*)action
{
- if (_SOAPAction != action)
+ if (NO == [_SOAPAction isEqual: action])
{
NSString *old = _SOAPAction;
@@ -1709,8 +1750,7 @@
[_lock lock];
if (nil != _ioThread)
{
- _completedIO = YES;
- threadRem(&_ioThread);
+ [self _completedIO];
[_connection cancel];
}
[_lock unlock];
@@ -1748,19 +1788,23 @@
* the cancellation of the request I/O if necessary.
*/
[_lock lock];
- if (t == _timer)
- {
- [self _setProblem: @"timed out"];
+ if (NO == _cancelled && NO == _completedIO)
+ {
+ if (t == _timer)
+ {
+ [self _setProblem: @"timed out"];
+ }
}
else
{
- /* We invalidate the timer: otherwise we could get a timeout just after
- * cancelling ... which would change our problem report from 'cancelled'
- */
- [_timer invalidate];
[self _setProblem: @"cancelled"];
}
+ /* We invalidate the timer: otherwise we could get a timeout just after
+ * cancelling ... which would change our problem report from 'cancelled'
+ */
+ [_timer invalidate];
_timer = nil;
+
if (NO == notYetActive)
{
if (NO == _cancelled && NO == _completedIO)
@@ -1841,14 +1885,12 @@
didFailWithError: (NSError*)error
{
[_lock lock];
- _completedIO = YES;
- threadRem(&_ioThread);
+ [self _completedIO];
+ if (NO == _cancelled)
+ {
+ [self _setProblem: [error localizedDescription]];
+ }
[_lock unlock];
-
- if (NO == _cancelled)
- {
- [self _setProblem: [error localizedDescription]];
- }
[self _completed];
}
@@ -1884,8 +1926,7 @@
- (void) connectionDidFinishLoading: (NSURLConnection*)connection
{
[_lock lock];
- _completedIO = YES;
- threadRem(&_ioThread);
+ [self _completedIO];
_stage = RPCParsing;
[_lock unlock];
@@ -1985,14 +2026,13 @@
*/
[[self retain] autorelease];
[_lock lock];
- _completedIO = YES;
- threadRem(&_ioThread);
- [_lock unlock];
+ [self _completedIO];
[handle removeClient: (id<NSURLHandleClient>)self];
if (NO == _cancelled)
{
[self _setProblem: reason];
}
+ [_lock unlock];
[self _completed];
}
@@ -2008,9 +2048,7 @@
*/
[[self retain] autorelease];
[_lock lock];
- _completedIO = YES;
- threadRem(&_ioThread);
- [_lock unlock];
+ [self _completedIO];
[handle removeClient: (id<NSURLHandleClient>)self];
if (NO == _cancelled)
{
@@ -2027,6 +2065,7 @@
}
[self _setProblem: str];
}
+ [_lock unlock];
[self _completed];
}
@@ -2037,14 +2076,13 @@
*/
[[self retain] autorelease];
[_lock lock];
- _completedIO = YES;
- threadRem(&_ioThread);
+ [self _completedIO];
_stage = RPCParsing;
- [_lock unlock];
[handle removeClient: (id<NSURLHandleClient>)self];
[_response release];
_response = [[handle availableResourceData] mutableCopy];
_code = [[handle propertyForKey: NSHTTPPropertyStatusCodeKey] intValue];
+ [_lock unlock];
if ([workThreads maxThreads] == 0
&& [NSThread currentThread] != _queueThread)
{
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs