Ejemplo n.º 1
0
Archivo: mount.js Proyecto: olegp/stick
            match: function(req) {
                var host = req.headers.get("host") || "";
                var path = req.pathInfo || "/";

                return (!spec.host || (host && strings.endsWith(host, spec.host)))
                    && (!spec.path || path === spec.path
                                   || (path && strings.startsWith(path, spec.canonicalPath)));
            },
Ejemplo n.º 2
0
 get: function() {
     if (!postParams) {
         Headers(req.headers);
         var contentType = req.headers.get("content-type");
         if (req.method === "POST" || req.method === "PUT") {
             var input;
             var encoding = servletRequest.getCharacterEncoding() || "utf8";
             if (isUrlEncoded(contentType)) {
                 postParams = {};
                 input = req.input.read();
                 var contentLength = parseInt(req.headers.get("content-length"));
                 if (!input.length && contentLength > 0) {
                     // Entity body already consumed, ask servlet API for params
                     // See ringo issues #70 and #130
                     var map = servletRequest.getParameterMap();
                     for (var entry in Iterator(map.entrySet())) {
                         var key = entry.key, value = entry.value;
                         // value is a java string array
                         for (var val in value) {
                             mergeParameter(postParams, key, value[val]);
                         }
                     }
                 } else {
                     parseParameters(input, postParams, encoding);
                 }
             } else if (strings.startsWith(contentType, "application/json")) {
                 input = req.input.read();
                 postParams = JSON.parse(input.decodeToString(encoding));
             }
         }
         // query previous postParams property descriptor in case
         // this is a file upload
         if (!postParams && desc) {
             postParams = desc.get ? desc.get.apply(req) : desc.value;
         }
     }
     return postParams;
 }, configurable: true