예제 #1
0
 /**
  * Checks if the produced content type matches.
  *
  * @param http http context
  * @return result of check
  */
 private boolean produces(final HTTPContext http) {
   // return true if no type is given
   if (produces.isEmpty()) return true;
   // check if any combination matches
   for (final String pr : http.produces()) {
     for (final String p : produces) {
       if (MimeTypes.matches(p, pr)) return true;
     }
   }
   return false;
 }
예제 #2
0
 /**
  * Checks if the consumed content type matches.
  *
  * @param http http context
  * @return result of check
  */
 private boolean consumes(final HTTPContext http) {
   // return true if no type is given
   if (consumes.isEmpty()) return true;
   // return true if no content type is specified by the user
   final String ct = http.contentType();
   if (ct == null) return true;
   // check if any combination matches
   for (final String c : consumes) {
     if (MimeTypes.matches(c, ct)) return true;
   }
   return false;
 }