Package org.tamacat.httpd.core

Examples of org.tamacat.httpd.core.RequestParameters


        }
      } catch (FileUploadException e) {
        throw new RequestParseException(e.getMessage(), e);
      }
    } else {
      RequestParameters p = RequestUtils.getParameters(context);
      for (String name : p.getParameterNames()) {
        String[] values = p.getParameters(name);
        if (values != null && values.length > 0) {
          params.put(name, values[0]);
        }
      }
    }
View Full Code Here


    }
    return path;
  }
 
  public static void setParameter(HttpContext context, String name, String... values) throws IOException {
    RequestParameters parameters = getParameters(context);
    parameters.setParameter(name, values);
  }
View Full Code Here

 
  public static void setParameters(
      HttpRequest request, HttpContext context, String encoding) {
    String path = request.getRequestLine().getUri();
    //String path = docsRoot + request.getRequestLine().getUri();
    RequestParameters parameters = getParameters(context);

    if (path.indexOf('?') >= 0) {
      String[] requestParams = path.split("\\?");
      //path = requestParams[0];
      //set request parameters for Custom HttpRequest.
      if (requestParams.length >= 2) {
        String params = requestParams[1];
        String[] param = params.split("&");
        for (String kv : param) {
          String[] p = kv.split("=");
          if (p.length >=2) {
            parameters.setParameter(p[0], decode(p[1], encoding));
          }
        }
      }
    }
    if (isEntityEnclosingRequest(request) && ! RequestUtils.isMultipart(request)) {
      HttpEntity entity = getEntity(request);
      if (entity != null) {
        InputStream in = null;
        BufferedReader reader = null;
        try {
          in = entity.getContent();
          reader = new BufferedReader(new InputStreamReader(in)); //8192byte buffers
          String s;
          StringBuilder sb = new StringBuilder();
          while ((s = reader.readLine()) != null) {
            sb.append(s);
          }
          String[] params = sb.toString().split("&");
          for (String param : params) {
            String[] keyValue = param.split("=");
            if (keyValue.length >= 2) {
              parameters.setParameter(keyValue[0],
                  decode(keyValue[1], encoding));
            }
          }
        } catch (IOException e) {
          throw new HttpException(BasicHttpStatus.SC_BAD_REQUEST, e);
View Full Code Here

    context.setAttribute(REQUEST_PARAMETERS_CONTEXT_KEY, parameters);
  }
 
  public static RequestParameters getParameters(HttpContext context) {
    synchronized (context) {
      RequestParameters params = (RequestParameters) context.getAttribute(REQUEST_PARAMETERS_CONTEXT_KEY);
      if (params == null) {
        params = new RequestParameters();
        context.setAttribute(REQUEST_PARAMETERS_CONTEXT_KEY, params);
      }
      return params;
    }
  }
View Full Code Here

      return params;
    }
  }
 
  public static String getParameter(HttpContext context, String name) {
    RequestParameters params = getParameters(context);
    return params != null ? params.getParameter(name) : null;
  }
View Full Code Here

    RequestParameters params = getParameters(context);
    return params != null ? params.getParameter(name) : null;
  }
 
  public static String[] getParameters(HttpContext context, String name) {
    RequestParameters params = getParameters(context);
    return params != null ? params.getParameters(name) : null;
  }
View Full Code Here

    RequestParameters params = getParameters(context);
    return params != null ? params.getParameters(name) : null;
  }
 
  public static Set<String> getParameterNames(HttpContext context) {
    RequestParameters params = getParameters(context);
    return params != null ? params.getParameterNames() : null;
  }
View Full Code Here

    RequestUtils.setParameters(request, context, "UTF-8");
  }
 
  @Test
  public void testSetParametersHttpContextRequestParameters() throws Exception {
    RequestParameters params = new RequestParameters();
    params.setParameter("key1", "value1");
    RequestUtils.setParameters(context, params);
  }
View Full Code Here

TOP

Related Classes of org.tamacat.httpd.core.RequestParameters

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.