Пример #1
0
 get: function() {
     if (!queryParams) {
         queryParams = {};
         var encoding = req.env.servletRequest.getCharacterEncoding();
         parseParameters(this.queryString, queryParams, encoding);
     }
     return queryParams;
 }, configurable: true
Пример #2
0
 getResponse = function(req) {
     var params = {};
     parseParameters(req.queryString, params);
     // set cookie
     var res = html('cookie set');
     res.headers['Set-Cookie'] = setCookie(COOKIE_NAME, params.cookievalue, 5);
     return res;
 };
Пример #3
0
 getResponse = function(req) {
     var params = {};
     var input = req.method == "POST" ? req.input.read() : req.queryString;
     parseParameters(input, params);
     if (params.foo) {
         return response.html(req.method + " with param");
     }
     return response.html(req.method);
 };
Пример #4
0
 getResponse = function(req) {
     var params = {};
     parseParameters(req.queryString, params);
     // set cookie
     var res = response.html("cookie set");
     res.headers["Set-Cookie"] = setCookie(COOKIE_NAME,
             params.cookievalue, COOKIE_DAYS, {
                 "domain": "localhost",
                 "secure": true
             });
     return res;
 };
Пример #5
0
 get: function() {
     if (!postParams) {
         var contentType = req.env.servletRequest.getContentType();
         if (req.method === "POST" || req.method === "PUT") {
             if (isUrlEncoded(contentType)) {
                 postParams = {};
                 var encoding = req.env.servletRequest.getCharacterEncoding();
                 parseParameters(this.input.read(), postParams, encoding);
             } else if (contentType === "application/json") {
                 postParams = JSON.parse(this.input.read().decodeToString(encoding));
             }
         }
         if (!postParams && desc) {
             postParams = desc.get ? desc.get.apply(req) : desc.value;
         }
     }
     return postParams;
 }, configurable: true
Пример #6
0
function parseParameters(req) {
	var input = req.input.read();
	var params = null;
	
	// handle json and application/x-www-form-urlencoded input
	if (req.headers["content-type"] === "application/json") {
		var inputString = decodeToString(input);
		params = eval('(' + inputString + ')');
	} else {
		params = utils.parseParameters(input);		
	}
	
	print("params {");
	for (var key in params) {
		print("  " + key + " = " + params[key]);
	}
	print("} // params");	
	
	return params;
}
Пример #7
0
 testCases.forEach(function(test, index) {
     assert.deepEqual(http.parseParameters(test[0]), test[1], "testCase[" + index + "] failed! " + test[0]);
 });
Пример #8
0
 getResponse = function(req) {
     var params = {};
     var input = req.method == "POST" ? req.input.read() : req.queryString;
     parseParameters(input, params);
     return response.json(params);
 };