[英]How to set the charset in request using apache httpclient fluent 4.3.2
Request.config(CoreProtocolPNames.HTTP_CONTENT_CHARSET, Consts.UTF_8)
and Request.elementCharset(charset)
are Deprecated. Request.config(CoreProtocolPNames.HTTP_CONTENT_CHARSET, Consts.UTF_8)
和Request.elementCharset(charset)
已弃用。
Now how to set the request charset to utf-8 with fluent? 现在如何使用流畅的方式将请求字符集设置为utf-8?
Request.Post(url)
.useExpectContinue()
.version(HttpVersion.HTTP_1_1)
.bodyString("Important stuff", ContentType.DEFAULT_TEXT)
.execute().returnContent().asBytes();
That would be the right way doing it 这将是正确的做法
Request.Post("someurl")
.useExpectContinue()
.version(HttpVersion.HTTP_1_1)
.bodyString("Important stuff", ContentType.create("text/plain", Consts.UTF_8))
.execute()
.returnContent().asBytes();
尝试
Request.setHeader(CoreProtocolPNames.HTTP_CONTENT_CHARSET, Consts.UTF_8);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.