!htp #19034 refactor content negotiation, upgrade to new MediaType / ContentType model

This commit is contained in:
Mathias 2015-12-01 23:07:56 +01:00
parent e9240b7d86
commit 899b92faf2
46 changed files with 652 additions and 403 deletions

View file

@ -35,7 +35,7 @@ public class ModelDocTest {
Authorization authorization = Authorization.basic("user", "pass");
HttpRequest complexRequest =
HttpRequest.PUT("/user")
.withEntity(HttpEntities.create(MediaTypes.TEXT_PLAIN.toContentType(), "abc"))
.withEntity(HttpEntities.create(ContentTypes.TEXT_PLAIN_UTF8, "abc"))
.addHeader(authorization)
.withProtocol(HttpProtocols.HTTP_1_0);
//#construct-request

View file

@ -51,7 +51,7 @@ public class HighLevelServerExample extends HttpApp {
// matches the empty path
pathSingleSlash().route(
// return a constant string with a certain content type
complete(ContentTypes.TEXT_HTML,
complete(ContentTypes.TEXT_HTML_UTF8,
"<html><body>Hello world!</body></html>")
),
path("ping").route(

View file

@ -156,7 +156,7 @@ public class HttpServerExampleDocTest {
.via(failureDetection)
.map(request -> {
Source<ByteString, Object> bytes = request.entity().getDataBytes();
HttpEntity.Chunked entity = HttpEntities.create(ContentTypes.TEXT_PLAIN, bytes);
HttpEntityChunked entity = HttpEntities.create(ContentTypes.TEXT_PLAIN_UTF8, bytes);
return HttpResponse.create()
.withEntity(entity);
@ -199,7 +199,7 @@ public class HttpServerExampleDocTest {
if (uri.path().equals("/"))
return
HttpResponse.create()
.withEntity(ContentTypes.TEXT_HTML,
.withEntity(ContentTypes.TEXT_HTML_UTF8,
"<html><body>Hello world!</body></html>");
else if (uri.path().equals("/hello")) {
String name = Util.getOrElse(uri.query().get("name"), "Mister X");