@Override public String contentType() { return request.getContentType().getType(); }
/** * This determines the charset for <code>PrintStream</code> objects * returned from the <code>getPrintStream</code> method. This will * return a valid charset regardless of whether the Content-Type * header has been set, set without a charset, or not set at all. * If unspecified, the charset returned is <code>ISO-8859-1</code>, * as suggested by RFC 2616, section 3.7.1. * * @return returns the charset used by this response object */ private String getCharset() { ContentType type = getContentType(); if(type == null) { return "ISO-8859-1"; } if(type.getCharset()==null){ return "ISO-8859-1"; } return type.getCharset(); }
/** * This is used to determine if the content type is a form POST * of type application/x-www-form-urlencoded. Such a type is * used when a HTML form is used to post data to the server. * * @param type the type to determine if its a form post * * @return this returns true if content type is a form post */ private boolean isFormPost(ContentType type) { String primary = type.getPrimary(); String secondary = type.getSecondary(); if(!primary.equals(APPLICATION)) { return false; } return secondary.equals(URL_ENCODED); } }
/** * This is used to extract information from the HTTP header that * can be used to determine the type of the body. This will look * at the HTTP headers provided to find a specific token which * enables it to determine how to consume the body. * * @param segment this is the header associated with the body * * @return true if the content type is that of a multipart body */ protected boolean isUpload(Segment segment) { ContentType type = segment.getContentType(); if(type != null) { String token = type.getPrimary(); if(token.equals(MULTIPART)) { return true; } } return false; }
/** * This is used to extract information from the HTTP header that * can be used to determine the type of the body. This will look * at the HTTP headers provided to find a specific token which * enables it to determine how to consume the body. * * @param header this is the header associated with the body * * @return the boundary for a multipart upload body */ protected byte[] getBoundary(Segment header) { ContentType type = header.getContentType(); if(type != null) { String token = type.getParameter(BOUNDARY); if(token != null) { return token.getBytes(); } } return null; }
@Override public String contentType() { return part.getContentType().toString(); }
/** * This is used to extract information from the HTTP header that * can be used to determine the type of the body. This will look * at the HTTP headers provided to find a specific token which * enables it to determine how to consume the body. * * @param segment this is the header associated with the body * * @return true if the content type is that of a multipart body */ protected boolean isUpload(Segment segment) { ContentType type = segment.getContentType(); if(type != null) { String token = type.getPrimary(); if(token.equals(MULTIPART)) { return true; } } return false; }
/** * This is used to extract information from the HTTP header that * can be used to determine the type of the body. This will look * at the HTTP headers provided to find a specific token which * enables it to determine how to consume the body. * * @param header this is the header associated with the body * * @return the boundary for a multipart upload body */ protected byte[] getBoundary(Segment header) { ContentType type = header.getContentType(); if(type != null) { String token = type.getParameter(BOUNDARY); if(token != null) { return token.getBytes(); } } return null; }
if (item == null) { String filename = truncateFileName(getUserAgentHeader(), part.getFileName());; item = new SimpleFileItem(name, part.getContentType().toString(), filename); files.put(name, item);
/** * This is used to determine if the content type is a form POST * of type application/x-www-form-urlencoded. Such a type is * used when a HTML form is used to post data to the server. * * @param type the type to determine if its a form post * * @return this returns true if content type is a form post */ private boolean isFormPost(ContentType type) { String primary = type.getPrimary(); String secondary = type.getSecondary(); if(!primary.equals(APPLICATION)) { return false; } return secondary.equals(URL_ENCODED); } }
@Override public String getContentType() { return request.getContentType().getType(); }
/** * This determines the charset for <code>PrintStream</code> objects * returned from the <code>getPrintStream</code> method. This will * return a valid charset regardless of whether the Content-Type * header has been set, set without a charset, or not set at all. * If unspecified, the charset returned is <code>ISO-8859-1</code>, * as suggested by RFC 2616, section 3.7.1. * * @return returns the charset used by this response object */ private String getCharset() { ContentType type = getContentType(); if(type == null) { return "ISO-8859-1"; } if(type.getCharset()==null){ return "ISO-8859-1"; } return type.getCharset(); }
/** * This is used to extract information from the HTTP header that * can be used to determine the type of the body. This will look * at the HTTP headers provided to find a specific token which * enables it to determine how to consume the body. * * @param segment this is the header associated with the body * * @return true if the content type is that of a multipart body */ protected boolean isUpload(Segment segment) { ContentType type = segment.getContentType(); if(type != null) { String token = type.getPrimary(); if(token.equals(MULTIPART)) { return true; } } return false; }
/** * This is used to extract information from the HTTP header that * can be used to determine the type of the body. This will look * at the HTTP headers provided to find a specific token which * enables it to determine how to consume the body. * * @param header this is the header associated with the body * * @return the boundary for a multipart upload body */ protected byte[] getBoundary(Segment header) { ContentType type = header.getContentType(); if(type != null) { String token = type.getParameter(BOUNDARY); if(token != null) { return token.getBytes(); } } return null; }
/** * This is used to determine if the content type is a form POST * of type application/x-www-form-urlencoded. Such a type is * used when a HTML form is used to post data to the server. * * @param type the type to determine if its a form post * * @return this returns true if content type is a form post */ private boolean isFormPost(ContentType type) { String primary = type.getPrimary(); String secondary = type.getSecondary(); if(!primary.equals(APPLICATION)) { return false; } return secondary.equals(URL_ENCODED); } }
@Override public String getContentType() { return request.getContentType().getType(); }
/** * This determines the charset for <code>PrintStream</code> objects * returned from the <code>getPrintStream</code> method. This will * return a valid charset regardless of whether the Content-Type * header has been set, set without a charset, or not set at all. * If unspecified, the charset returned is <code>ISO-8859-1</code>, * as suggested by RFC 2616, section 3.7.1. * * @return returns the charset used by this response object */ private String getCharset() { ContentType type = getContentType(); if(type == null) { return "ISO-8859-1"; } if(type.getCharset()==null){ return "ISO-8859-1"; } return type.getCharset(); }
public String getContentType() { return request.getContentType().getType(); }
/** * This is used to get the content body. This will essentially get * the content from the body and present it as a single string. * The encoding of the string is determined from the content type * charset value. If the charset is not supported this will throw * an exception. Typically only text values should be extracted * using this method if there is a need to parse that content. * * @param type this is the content type used with the request * * @return the input stream containing the message body */ public String getContent(ContentType type) throws IOException { String charset = type.getCharset(); if(charset == null) { charset = "ISO-8859-1"; } return body.getContent(charset); }
public ResolvedRequest resolve(Request request) { ResolvedRequest resolved = new ResolvedRequest(); String method = request.getMethod(); String path = RequestUtils.getUndecodedPath(request); ContentType requestContentType = request.getContentType(); /* get the route and the handler for this request */ Route route = router.route(path); if (route == null) { logger.error("could not find a route for " + path); resolved.errorStatus = Status.NOT_FOUND; return resolved; } String contentType = requestContentType != null ? requestContentType.getType() : null; HandlerKey key = new HandlerKey(method, route, contentType); RequestHandlerImpl handler = handlerMap.get(key); if (handler == null) { logger.error("could not find a handler for " + method + " - " + path + " - " + contentType); resolved.errorStatus = Status.METHOD_NOT_ALLOWED; return resolved; } resolved.handler = handler; resolved.route = route; resolved.key = key; return resolved; }