[self debugWithFormat:@" wrote accept header ..."];
}
if ([_request headerForKey:@"user-agent"] == nil) {
- if (isok) isok = [self->io writeString:@"User-Agent: SOPE/4.2\r\n"];
+ if (isok) {
+ static NSString *s = nil;
+ if (s == nil) {
+ s = [[NSString alloc] initWithFormat:@"User-Agent: SOPE/%i.%i.%i\r\n",
+ SOPE_MAJOR_VERSION, SOPE_MINOR_VERSION,
+ SOPE_SUBMINOR_VERSION];
+ }
+ isok = [self->io writeString:s];
+ }
[self debugWithFormat:@" wrote user-agent header ..."];
}
xslPath = nil;
response = [WOResponse responseWithRequest:[self request]];
- [response setHeader:@"text/xml" forKey:@"content-type"];
+ [response setContentEncoding:NSUTF8StringEncoding];
+ [response setHeader:@"text/xml; charset=utf-8" forKey:@"content-type"];
stats = [[app statisticsStore] statistics];
[response appendContentString:@"<?xml version='1.0'?>\n"];
-#if 1
if ([xslPath length] > 0) {
[response appendContentString:@"<?xml-stylesheet type='text/xsl' href='"];
[response appendContentString:xslPath];
[response appendContentString:@"'?>"];
}
-#endif
+
[response appendContentString:@"<application name='"];
[response appendContentString:[app name]];
[response appendContentString:@"'"];
if ((tmp = [_r headerForKey:@"server"]) == nil) {
// TODO: add application name as primary name
- [_r setHeader:@"SOPE 4.2/WebDAV" forKey:@"server"];
+ static NSString *server = nil;
+
+ if (server == nil) {
+ server = [[NSString alloc] initWithFormat:@"SOPE %i.%i.%i/WebDAV",
+ SOPE_MAJOR_VERSION, SOPE_MINOR_VERSION,
+ SOPE_SUBMINOR_VERSION];
+ }
+
+ [_r setHeader:server forKey:@"server"];
}
[_r setHeader:@"close" forKey:@"connection"];
/* generate multistatus */
[r setStatus:207 /* multistatus */];
+ [r setContentEncoding:NSUTF8StringEncoding];
+ [r setHeader:@"text/xml; charset=\"utf-8\"" forKey:@"content-type"];
[r setHeader:@"no-cache" forKey:@"pragma"];
[r setHeader:@"no-cache" forKey:@"cache-control"];
r = [_ctx response];
- [r setStatus:200];
+ [r setStatus:200 /* OK */];
[r setContentEncoding:NSUTF8StringEncoding];
[r setHeader:@"text/xml; charset=\"utf-8\"" forKey:@"content-type"];
[r setHeader:[_object stringValue] forKey:@"lock-token"];
notificationType = [rq headerForKey:@"notification-type"];
lifetime = [rq headerForKey:@"subscription-lifetime"];
- [r setStatus:200];
- if (notificationType)
+ [r setStatus:200 /* OK */];
+ if (notificationType != nil)
[r setHeader:notificationType forKey:@"notification-type"];
- if (lifetime)
+ if (lifetime != nil)
[r setHeader:lifetime forKey:@"subscription-lifetime"];
- if (callback)
+ if (callback != nil)
[r setHeader:callback forKey:@"callback"];
[r setHeader:[self baseURLForContext:_ctx] forKey:@"content-location"];
[r setHeader:_object forKey:@"subscription-id"];
nsToPrefix:nsToPrefix];
[r setStatus:207 /* multistatus */];
+ [r setContentEncoding:NSUTF8StringEncoding];
+ [r setHeader:@"text/xml; charset=\"utf-8\"" forKey:@"content-type"];
[r appendContentString:@"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"];
[r appendContentString:@"<D:multistatus"];
[r appendContentString:[self nsDeclsForMap:nsToPrefix]];
inactive = [_object objectForKey:@"inactive"];
[r setStatus:207 /* Multi-Status */];
- [r setHeader:@"text/xml" forKey:@"content-type"];
+ [r setContentEncoding:NSUTF8StringEncoding];
+ [r setHeader:@"text/xml; charset=\"utf-8\"" forKey:@"content-type"];
[r appendContentString:@"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"];
[r appendContentString:@"<D:multistatus "];
}
else if ([_object isKindOfClass:[NSArray class]]) {
[r setStatus:207 /* Multi-Status */];
- [r setHeader:@"text/xml" forKey:@"content-type"];
+ [r setContentEncoding:NSUTF8StringEncoding];
+ [r setHeader:@"text/xml; charset=\"utf-8\"" forKey:@"content-type"];
[r appendContentString:@"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"];
[r appendContentString:@"<D:multistatus "];