public enum ContentType extends Enum<ContentType>
http.request( GET, JSON ) {...}Is roughly equivalent to:
http.request( GET, 'application/json' )The only difference being, equivalent content-types (i.e.
application/xml
and text/xml
are all added to the
request's Accept
header. By default, all equivalent content-types
are handled the same by the EncoderRegistry
and HttpResponseContentTypeFinder
as well.Enum Constant and Description |
---|
ANY
*/* |
BINARY
application/octet-stream |
HTML
text/html |
JSON
application/json
application/javascript
text/javascript
|
MULTIPART
multipart/form-data
multipart/alternative
multipart/byteranges
multipart/digest
multipart/mixed
multipart/parallel
multipart/related
multipart/report
multipart/signed
multipart/encrypted
|
TEXT
text/plain |
URLENC
application/x-www-form-urlencoded |
XML
application/xml
text/xml
application/xhtml+xml
|
Modifier and Type | Method and Description |
---|---|
static ContentType |
fromContentType(String contentType) |
String |
getAcceptHeader()
Builds a string to be used as an HTTP
Accept header
value, i.e. |
String[] |
getContentTypeStrings() |
boolean |
matches(String contentType) |
String |
toString() |
static ContentType |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static ContentType[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
String |
withCharset(Charset charset)
Specify a charset for this content-type
|
String |
withCharset(String charset)
Specify a charset for this content-type
|
public static final ContentType ANY
*/*
public static final ContentType TEXT
text/plain
public static final ContentType JSON
application/json
application/javascript
text/javascript
public static final ContentType XML
application/xml
text/xml
application/xhtml+xml
public static final ContentType HTML
text/html
public static final ContentType URLENC
application/x-www-form-urlencoded
public static final ContentType BINARY
application/octet-stream
public static final ContentType MULTIPART
multipart/form-data
multipart/alternative
multipart/byteranges
multipart/digest
multipart/mixed
multipart/parallel
multipart/related
multipart/report
multipart/signed
multipart/encrypted
public static ContentType[] values()
for (ContentType c : ContentType.values()) System.out.println(c);
public static ContentType valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic String[] getContentTypeStrings()
public String toString()
toString
in class Enum<ContentType>
public String getAcceptHeader()
Accept
header
value, i.e. "application/xml, text/xml"public String withCharset(Charset charset)
charset
- The charsetpublic String withCharset(String charset)
charset
- The charsetpublic static ContentType fromContentType(String contentType)
public boolean matches(String contentType)
Copyright © 2010–2023. All rights reserved.