Author: hannes
Date: 2009-01-15 12:27:26 +0100 (Thu, 15 Jan 2009)
New Revision: 9483
Modified:
helma-ng/trunk/src/org/helma/web/Request.java
Log:
Remove getCookies() and getHeader() from Request object, and add contentType and contentLength properties.
Details at http://dev.helma.org/trac/helma/changeset/9483
Modified: helma-ng/trunk/src/org/helma/web/Request.java
===================================================================
--- helma-ng/trunk/src/org/helma/web/Request.java 2009-01-15 11:27:11 UTC (rev 9482)
+++ helma-ng/trunk/src/org/helma/web/Request.java 2009-01-15 11:27:26 UTC (rev 9483)
@@ -39,7 +39,7 @@
private HttpServletRequest request;
private Session session;
- private Scriptable cookies, data, params, headers, attributes;
+ private Scriptable cookies, params, headers;
private static final long serialVersionUID = -2167096504665220425L;
public Request() {
@@ -174,15 +174,23 @@
}
/**
- * Returns the value of the specified request header as String.
- * @param name the header name
- * @return the header value as String, or null if the header doesn't exist
+ * Property to get the Content-Type header of the current HTTP request.
+ * @return the MIME content type
*/
- public String jsFunction_getHeader(String name) {
- return request.getHeader(name);
+ public String jsGet_contentType() {
+ return request.getContentType();
}
/**
+ * The length, in bytes, of the request body and made available by the input stream,
+ * or -1 if the length is not known.
+ * @return the length of the request body
+ */
+ public int jsGet_contentLength() {
+ return request.getContentLength();
+ }
+
+ /**
* Returns the value of the specified request header as JavaScript array of Strings.
* @param name the header name
* @return the header value as Array of Strings
@@ -223,10 +231,11 @@
public Object jsGet_headers() {
if (headers == null) {
Map<String,String> headerMap = new HashMap<String,String>();
- Enumeration headerEnum = request.getHeaderNames();
- while (headerEnum.hasMoreElements()) {
- String name = (String) headerEnum.nextElement();
- headerMap.put(name, request.getHeader(name));
+ for (Enumeration e = request.getHeaderNames(); e.hasMoreElements(); ) {
+ String name = (String) e.nextElement();
+ if (!headerMap.containsKey(name)) {
+ headerMap.put(name, request.getHeader(name));
+ }
}
headers = new ScriptableMap(getParentScope(),
new CaseInsensitiveMap<String,String>(headerMap));
@@ -268,9 +277,9 @@
* Otherwise, it is more convenient to use the *req.cookies|cookies* object.
* @return a JavaScript array with the request's cookie objects
*/
- public Object jsFunction_getCookies() {
+ /* public Object jsFunction_getCookies() {
return getJsArray(request.getCookies());
- }
+ } */
public String getClassName() {
return "Request";
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.