When running on an Internet Information Server (IIS) Web server, WebObjects 4.5 applications that set cookies cannot retrieve them later.
Solution
An IIS Web server modifies the standard Hypertext Transfer Protocol (HTTP) "Cookie" header to be "HTTP_COOKIE". A WebObjects 4.5 application, which looks for "Cookie" headers, is therefore unable to retrieve cookies. WebObjects 4.5 applications running through IIS must look for an "HTTP_COOKIE" header. There are two possible solutions:
Solution 1: Application Code
In the "Application" object dispatchRequest method, before you call super.dispatchRequest(), take the request object and read all the "HTTP_COOKIE" headers. Add a new header for each one, using "cookie" as the header key instead.
In Java, add this to Application.java:
public WOResponse dispatchRequest(WORequest aRequest) {
NSArray isapiCookieHeaders = aRequest.headersForKey("HTTP_COOKIE");
if (isapiCookieHeaders != null) {
for (int i=0; i<isapiCookieHeaders.count(); i++)
aRequest.setHeader((String)isapiCookieHeaders.objectAtIndex(i),
"cookie");
}
return super.dispatchRequest(aRequest);
}
In Objective-C, add this to Application.m
(WOResponse*) dispatchRequest:(WORequest *) aRequest {
NSArray *isapiCookieHeaders = [aRequest headersForKey:@"HTTP_COOKIE"];
int i;
if (isapiCookieHeaders != nil) {
for (i = 0; i < [isapiCookieHeaders count]; i++)
[aRequest setHeader:[isapiCookieHeaders
objectAtIndex:i] forKey:@"cookie"];
}
return [super dispatchRequest:aRequest];
}
Solution 2: ISAPI Adaptor Code
There are no code changes to your WebObjects application, but it does require recompilation of the ISAPI adaptor.
In config.h, look for the following #define:
#define COOKIE "cookie"
and change it to:
#define COOKIE "HTTP_COOKIE"