Example #1
0
 @Override
 public void parseRequestParameters(
     final Map<String, String> params, final Map<String, com.bradmcevoy.http.FileItem> files)
     throws RequestParseException {
   try {
     if (isMultiPart()) {
       parseQueryString(params, req.getQueryString());
       @SuppressWarnings("unchecked")
       final List<FileItem> items = new ServletFileUpload().parseRequest(req);
       for (final FileItem item : items) {
         if (item.isFormField()) params.put(item.getFieldName(), item.getString());
         else files.put(item.getFieldName(), new FileItemWrapper(item));
       }
     } else {
       final Enumeration<String> en = req.getParameterNames();
       while (en.hasMoreElements()) {
         final String nm = en.nextElement();
         final String val = req.getParameter(nm);
         params.put(nm, val);
       }
     }
   } catch (final FileUploadException ex) {
     throw new RequestParseException("FileUploadException", ex);
   } catch (final Throwable ex) {
     throw new RequestParseException(ex.getMessage(), ex);
   }
 }
 protected void handleDocument(
     HttpServletRequest request, HttpServletResponse response, Document doc) throws IOException {
   if (request.getPathInfo().equalsIgnoreCase("/load")) getXmlScoreBoard().loadDocument(doc);
   else if (request.getPathInfo().equalsIgnoreCase("/merge"))
     getXmlScoreBoard().mergeDocument(doc);
   else
     response.sendError(
         HttpServletResponse.SC_NOT_FOUND, "Must specify to load or merge document");
   response.setContentType("text/plain");
   response.setStatus(HttpServletResponse.SC_OK);
 }
Example #3
0
 @Override
 public Map<String, String> getHeaders() {
   final Map<String, String> map = new HashMap<>();
   final Enumeration<String> en = req.getHeaderNames();
   while (en.hasMoreElements()) {
     final String name = en.nextElement();
     final String val = req.getHeader(name);
     map.put(name, val);
   }
   return map;
 }
Example #4
0
 @Override
 public Cookie getCookie(final String name) {
   for (final javax.servlet.http.Cookie c : req.getCookies()) {
     if (c.getName().equals(name)) return new BXServletCookie(c);
   }
   return null;
 }
Example #5
0
 @Override
 public String getRemoteAddr() {
   return req.getRemoteAddr();
 }
Example #6
0
 @Override
 public String getRequestHeader(final Header header) {
   return req.getHeader(header.code);
 }
Example #7
0
 @Override
 public String getFromAddress() {
   return req.getRemoteHost();
 }
Example #8
0
 /**
  * Constructor.
  *
  * @param r HTTP servlet request
  */
 BXServletRequest(final HttpServletRequest r) {
   req = r;
   method = Method.valueOf(r.getMethod());
   url = r.getRequestURL().toString(); // MiltonUtils.stripContext(r);
   REQUEST.set(r);
 }
Example #9
0
 /**
  * Request content type.
  *
  * @return the content type of the current request
  */
 private ContentType getRequestContentType() {
   final String s = req.getContentType();
   if (s == null) return null;
   if (s.contains(Response.MULTIPART)) return ContentType.MULTIPART;
   return TYPE_CONTENTS.get(s);
 }
Example #10
0
 @Override
 public List<Cookie> getCookies() {
   final List<Cookie> list = new ArrayList<>();
   for (final javax.servlet.http.Cookie c : req.getCookies()) list.add(new BXServletCookie(c));
   return list;
 }
Example #11
0
 @Override
 public InputStream getInputStream() throws IOException {
   return req.getInputStream();
 }