예제 #1
0
        private static void putRequestMap(Env env,
                                          ArrayValue post,
                                          ArrayValue files,
                                          QuercusHttpServletRequest request,
                                          bool addSlashesToValues,
                                          bool isAllowUploads)
        {
            // this call consumes the inputstream
            Map <String, String[]> map = request.getParameterMap();

            if (map == null)
            {
                return;
            }

            long maxFileSize = Long.MAX_VALUE;

            Value maxFileSizeV = post.get(env.createString("MAX_FILE_SIZE"));

            if (maxFileSizeV.isNull())
            {
                maxFileSize = maxFileSizeV.toLong();
            }

            if (isAllowUploads)
            {
                for (Map.Entry <String, String[]> entry : map.entrySet())
                {
                    string key = entry.getKey();

                    int len = key.length();

                    if (len < 10 || !key.endsWith(".filename"))
                    {
                        continue;
                    }

                    string name = key.substring(0, len - 9);

                    string [] fileNames = request.getParameterValues(name + ".filename");
                    string [] tmpNames  = request.getParameterValues(name + ".file");
                    string [] mimeTypes
                        = request.getParameterValues(name + ".content-type");

                    for (int i = 0; i < fileNames.length; i++)
                    {
                        long fileLength = new FilePath(tmpNames[i]).getLength();

                        addFormFile(env, files, name, fileNames[i], tmpNames[i],
                                    mimeTypes[i],
                                    fileLength,
                                    addSlashesToValues,
                                    maxFileSize);
                    }
                }
            }

            ArrayList <String> keys = new ArrayList <String>();

            keys.addAll(request.getParameterMap().keySet());

            Collections.sort(keys);

            for (String key : keys)
            {
                string [] value = request.getParameterValues(key);

                Post.addFormValue(env, post, key, value, addSlashesToValues, true);
            }
        }