changed helma.Http to correctly handle multiple cookies received from the remote server (fixes http://helma.org/bugs/show_bug.cgi?id=509).
This commit is contained in:
parent
72feb3356a
commit
52b3dca226
1 changed files with 37 additions and 7 deletions
|
@ -9,9 +9,9 @@
|
||||||
* Copyright 1998-2006 Helma Software. All Rights Reserved.
|
* Copyright 1998-2006 Helma Software. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* $RCSfile: Http.js,v $
|
* $RCSfile: Http.js,v $
|
||||||
* $Author: hannes $
|
* $Author: robert $
|
||||||
* $Revision: 1.3 $
|
* $Revision: 1.4 $
|
||||||
* $Date: 2006/11/21 10:42:25 $
|
* $Date: 2007/01/30 14:55:39 $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -219,6 +219,21 @@ helma.Http = function() {
|
||||||
return (cookies != null) ? cookies[name] : null;
|
return (cookies != null) ? cookies[name] : null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the cookies passed as argument to the list of cookies to send
|
||||||
|
* to the remote server.
|
||||||
|
* @param {Array} cookies An array containing objects with the properties
|
||||||
|
* "name" (the name of the cookie) and "value" (the value of the cookie) set.
|
||||||
|
*/
|
||||||
|
this.setCookies = function(cookies) {
|
||||||
|
if (cookies != null) {
|
||||||
|
for (var i=0; i<cookies.length; i++) {
|
||||||
|
this.setCookie(cookies[i].name, cookies[i].value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all cookies set for this client
|
* Returns all cookies set for this client
|
||||||
* @return An object containing all cookies, where the property
|
* @return An object containing all cookies, where the property
|
||||||
|
@ -418,14 +433,29 @@ helma.Http = function() {
|
||||||
type: conn.getContentType(),
|
type: conn.getContentType(),
|
||||||
encoding: conn.getContentEncoding(),
|
encoding: conn.getContentEncoding(),
|
||||||
lastModified: null,
|
lastModified: null,
|
||||||
eTag: null,
|
eTag: conn.getHeaderField("ETag"),
|
||||||
cookie: helma.Http.Cookie.parse(conn.getHeaderField("Set-Cookie")),
|
cookies: null,
|
||||||
content: null
|
content: null,
|
||||||
}
|
}
|
||||||
|
// parse all "Set-Cookie" header fields into an array of
|
||||||
|
// helma.Http.Cookie instances
|
||||||
|
var cookies = conn.getHeaderFields().get("Set-Cookie");
|
||||||
|
if (cookies != null) {
|
||||||
|
var arr = [];
|
||||||
|
var cookie;
|
||||||
|
for (var i=0; i<cookies.size(); i++) {
|
||||||
|
if ((cookie = helma.Http.Cookie.parse(cookies.get(i))) != null) {
|
||||||
|
arr.push(cookie);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (arr.length > 0) {
|
||||||
|
result.cookies = arr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var lastmod = conn.getLastModified();
|
var lastmod = conn.getLastModified();
|
||||||
if (lastmod)
|
if (lastmod)
|
||||||
result.lastModified = new Date(lastmod);
|
result.lastModified = new Date(lastmod);
|
||||||
result.eTag = conn.getHeaderField("ETag");
|
|
||||||
|
|
||||||
if (result.length != 0 && result.code == 200) {
|
if (result.length != 0 && result.code == 200) {
|
||||||
var body = new java.io.ByteArrayOutputStream();
|
var body = new java.io.ByteArrayOutputStream();
|
||||||
|
|
Loading…
Add table
Reference in a new issue