Package juzu.request

Examples of juzu.request.RequestParameter


    if (query != null) {
      for (Iterator<RequestParameter> i = Lexers.queryParser(query);i.hasNext();) {
        if (requestParameters.isEmpty()) {
          requestParameters = new HashMap<String, RequestParameter>();
        }
        RequestParameter parameter = i.next();
        parameter.appendTo(requestParameters);
      }
    }

    //
    if ("POST".equals(req.getMethod())) {
      String contentType = req.getContentType();
      if (contentType != null && contentType.length() > 0) {
        Spliterator i = new Spliterator(contentType, ';');
        if ("application/x-www-form-urlencoded".equals(i.next().trim())) {
          Charset charset = defaultEncoding;
          while (i.hasNext()) {
            String v = i.next().trim();
            if (v.startsWith("charset=")) {
              charset = Charset.forName(v.substring("charset=".length()));
            }
          }
          try {
            byte[] bytes = Tools.copy(req.getInputStream(), new ByteArrayOutputStream()).toByteArray();
            String form = new String(bytes, charset);
            FormURLEncodedParser parser = new FormURLEncodedParser(defaultEncoding, form, 0, form.length());
            for (RequestParameter parameter : parser) {
              if (requestParameters.isEmpty()) {
                requestParameters = new HashMap<String, RequestParameter>();
              }
              parameter.appendTo(requestParameters);
            }
          }
          catch (IOException e) {
            log.error("Cannot parse form post", e);
          }
View Full Code Here


        requestParameters = new HashMap<String, RequestParameter>();
        for (RequestParameter requestParameter : bridge.getRequestContext().getParameters().values()) {
          requestParameters.put(requestParameter.getName(), requestParameter);
        }
        for (Map.Entry<PathParam, String> entry : requestMatch.getMatched().entrySet()) {
          RequestParameter requestParameter = RequestParameter.create(entry.getKey().getName(), entry.getValue());
          requestParameters.put(requestParameter.getName(), requestParameter);
        }
      }
    }

    // No method means we either send a server resource
View Full Code Here

        for (int i = 0;i < args.length;i++) {
          ControlParameter parameter = handler.getParameters().get(i);
          Object value;
          if (parameter instanceof PhaseParameter) {
            PhaseParameter phaseParam = (PhaseParameter)parameter;
            RequestParameter requestParam = request.getParameterArguments().get(phaseParam.getMappedName());
            if (requestParam != null) {
              ValueType<?> valueType = request.controllerPlugin.resolveValueType(phaseParam.getValueType());
              if (valueType != null) {
                List values = new ArrayList(requestParam.size());
                for (String s : requestParam) {
                  Object converted;
                  try {
                    converted = valueType.parse(phaseParam.getAnnotations(), s);
                  }
View Full Code Here

  public static Map<String, RequestParameter> parseQuery(CharSequence s, int from, int to) {
    Map<String, RequestParameter> parameters = Collections.emptyMap();
    Iterator<RequestParameter> parser = queryParser(s, from, to);
    while (parser.hasNext()) {
      RequestParameter current = parser.next();
      if (parameters.isEmpty()) {
        parameters = new HashMap<String, RequestParameter>();
      }
      RequestParameter parameter = parameters.get(current.getName());
      if (parameter != null) {
        current = parameter.append(current);
      }
      parameters.put(current.getName(), current);
    }
    return parameters;
  }
View Full Code Here

        Map<String, RequestParameter> rp = Collections.emptyMap();
        for (ResponseParameter parameter : update.getParameters().values()) {
          if (rp.isEmpty()) {
            rp = new HashMap<String, RequestParameter>();
          }
          RequestParameter requestParameter = RequestParameter.create(parameter.getName(), parameter.toArray());
          rp.put(requestParameter.getName(), requestParameter);
        }
        WebViewBridge requestBridge = new WebViewBridge(bridge, handler, http, desc, rp);
        requestBridge.invoke();
        return requestBridge.send();
      } else {
View Full Code Here

      List<FileItem> list = (List<FileItem>)upload.parseRequest(ctx);
      HashMap<String, FileItem> files = new HashMap<String, FileItem>();
      for (FileItem file : list) {
        String name = file.getFieldName();
        if (file.isFormField()) {
          RequestParameter parameterArg = parameterArguments.get(name);
          if (parameterArg == null) {
            parameterArguments.put(name, RequestParameter.create(name, file.getString()));
          } else {
            parameterArguments.put(name, parameterArg.append(new String[]{file.getString()}));
          }
        } else {
          files.put(name, file);
        }
      }
View Full Code Here

  }

  @View
  @Route("/foo")
  public Response.Status foo() {
    RequestParameter param = context.getParameters().get("param");
    RequestFormContentTypeTestCase.param = param != null ? param.getValue() : null;
    return Response.ok();
  }
View Full Code Here

      public RequestParameter next() {
        if (!hasNext()) {
          throw new NoSuchElementException();
        }
        RequestParameter tmp = next;
        next = null;
        return tmp;
      }

      public void remove() {
View Full Code Here

      Assert(String s) {
        this.i = Lexers.queryParser(s, 0, s.length());
      }

      Assert assertParameter(String expectedName, String... expectedValue) {
        RequestParameter expected = RequestParameter.create(expectedName, expectedValue);
        if (i.hasNext()) {
          RequestParameter next = i.next();
          assertEquals(expected, next);
        } else {
          throw failure("Was expecting another parameter equals to " + expected);
        }
        return this;
View Full Code Here

      Assert(String s) {
        this.i = Lexers.queryParser(s, 0, s.length());
      }

      Assert assertParameter(String expectedName, String... expectedValue) {
        RequestParameter expected = RequestParameter.create(expectedName, expectedValue);
        if (i.hasNext()) {
          RequestParameter next = i.next();
          assertEquals(expected, next);
        } else {
          throw failure("Was expecting another parameter equals to " + expected);
        }
        return this;
View Full Code Here

TOP

Related Classes of juzu.request.RequestParameter

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.