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
|
TEXT
text/plain |
URLENC
application/x-www-form-urlencoded |
XML
application/json
application/javascript
text/javascript
|
| 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() |
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/plainpublic static final ContentType JSON
application/jsonapplication/javascripttext/javascriptpublic static final ContentType XML
application/jsonapplication/javascripttext/javascriptpublic static final ContentType HTML
text/htmlpublic static final ContentType URLENC
application/x-www-form-urlencodedpublic static final ContentType BINARY
application/octet-streampublic 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)
Copyright © 2010–2014. All rights reserved.