Jersey-Client content-type-header text/plain
Mit der jersey-client sendet HTTP-request. Content-Type-header wird automatisch als "application/json" (als Natur), aber ich will das ändern "content-type" header "text/plain" unabhängig von jeder Spezifikation, standards, etc. Jersey-version ist 2.4.1.
Code
String target = "http://192.168.1.2:10000";
String path = "test3";
Client c = ClientBuilder.newClient ();
WebTarget target = c.target (target).path (path);
Entity<SubscriberBean> json = Entity.json (subscriber);
Builder request = target.request ();
String response = request.post(json, String.class);
Anfrage
POST /test3 HTTP/1.1
Accept: text/html
Content-Type: application/json
User-Agent: Jersey/2.4.1 (HttpUrlConnection 1.6.0_17)
Host: 192.168.1.2:10000
Connection: keep-alive
Content-Length: 278
///**** Some json data ***///
InformationsquelleAutor Erdinç Taşkın | 2014-03-12
Du musst angemeldet sein, um einen Kommentar abzugeben.
statt
versuchen,
InformationsquelleAutor slartidan
Verwenden
Entity.text(entityData)
oderEntity.entity(entityData, mediaType)
Methoden stattEntity.json()
in deinem Beispiel.InformationsquelleAutor Oleg Estekhin