/** * Returns the <code>Content-Type</code> header on the request. * * <p> * The MIME type of the body of the request (used with POST and PUT requests). * * <h5 class='figure'>Example:</h5> * <p class='bcode w800'> * Content-Type: application/x-www-form-urlencoded * </p> * * @return The parsed <code>Content-Type</code> header on the request, or <jk>null</jk> if not found. */ public ContentType getContentType() { return ContentType.forString(getString("Content-Type")); }
/** * Returns the <code>Content-Type</code> header on the request. * * <p> * The MIME type of the body of the request (used with POST and PUT requests). * * <h5 class='figure'>Example:</h5> * <p class='bcode w800'> * Content-Type: application/x-www-form-urlencoded * </p> * * @return The parsed <code>Content-Type</code> header on the request, or <jk>null</jk> if not found. */ public ContentType getContentType() { return ContentType.forString(getString("Content-Type")); }
/** * Returns the <code>Content-Type</code> header on the request. * * <p> * The MIME type of the body of the request (used with POST and PUT requests). * * <h5 class='figure'>Example:</h5> * <p class='bcode w800'> * Content-Type: application/x-www-form-urlencoded * </p> * * @return The parsed <code>Content-Type</code> header on the request, or <jk>null</jk> if not found. */ public ContentType getContentType() { return ContentType.forString(getString("Content-Type")); }
/** * Searches the group for a parser that can handle the specified <l>Content-Type</l> header value. * * <p> * The returned object includes both the parser and media type that matched. * * @param contentTypeHeader The HTTP <l>Content-Type</l> header value. * @return The parser and media type that matched the content type header, or <jk>null</jk> if no match was made. */ public ParserMatch getParserMatch(String contentTypeHeader) { ParserMatch pm = cache.get(contentTypeHeader); if (pm != null) return pm; ContentType ct = ContentType.forString(contentTypeHeader); int match = ct.findMatch(mediaTypes); if (match >= 0) { pm = new ParserMatch(mediaTypes[match], mediaTypeParsers[match]); cache.putIfAbsent(contentTypeHeader, pm); } return cache.get(contentTypeHeader); }
/** * Searches the group for a parser that can handle the specified <l>Content-Type</l> header value. * * <p> * The returned object includes both the parser and media type that matched. * * @param contentTypeHeader The HTTP <l>Content-Type</l> header value. * @return The parser and media type that matched the content type header, or <jk>null</jk> if no match was made. */ public ParserMatch getParserMatch(String contentTypeHeader) { ParserMatch pm = cache.get(contentTypeHeader); if (pm != null) return pm; ContentType ct = ContentType.forString(contentTypeHeader); int match = ct.findMatch(mediaTypes); if (match >= 0) { pm = new ParserMatch(mediaTypes[match], mediaTypeParsers[match]); cache.putIfAbsent(contentTypeHeader, pm); } return cache.get(contentTypeHeader); }
/** * Searches the group for a parser that can handle the specified <l>Content-Type</l> header value. * * <p> * The returned object includes both the parser and media type that matched. * * @param contentTypeHeader The HTTP <l>Content-Type</l> header value. * @return The parser and media type that matched the content type header, or <jk>null</jk> if no match was made. */ public ParserMatch getParserMatch(String contentTypeHeader) { ParserMatch pm = cache.get(contentTypeHeader); if (pm != null) return pm; ContentType ct = ContentType.forString(contentTypeHeader); int match = ct.findMatch(mediaTypes); if (match >= 0) { pm = new ParserMatch(mediaTypes[match], mediaTypeParsers[match]); cache.putIfAbsent(contentTypeHeader, pm); } return cache.get(contentTypeHeader); }
@Test public void test() throws Exception { ContentType ct = ContentType.forString(this.contentType); MediaType[] mt = JsonParser.DEFAULT.parse(mediaTypes, MediaType[].class); int r = ct.findMatch(mt); TestUtils.assertEquals(expected, r, "{0} failed", label); } }