-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Dear ScribeJava,
Library: https://github.com/scribejava/scribejava/tree/master/scribejava-httpclient-apache
While building the request object:
Line 85 in 8970e8e
if (httpVerb.isPermitBody()) { |
I would like to ask you add a condition while adding the default 'Content-Type' header while preparing the requests, to verify the entity and if it's null then skip adding default 'Content-Type' header
private <T> Future<T> doExecuteAsync(String userAgent, Map<String, String> headers, Verb httpVerb,
String completeUrl, HttpEntity entity, OAuthAsyncRequestCallback<T> callback,
OAuthRequest.ResponseConverter<T> converter) {
final RequestBuilder builder = getRequestBuilder(httpVerb);
builder.setUri(completeUrl);
if (entity != null && httpVerb.isPermitBody()) {
if (!headers.containsKey(CONTENT_TYPE)) {
builder.addHeader(CONTENT_TYPE, DEFAULT_CONTENT_TYPE);
}
builder.setEntity(entity);
}
just like the implementation of OkHttpClient lib:
Line 140 in 8970e8e
if (bodyContents != null && HttpMethod.permitsRequestBody(method)) { |
I agree with your reasoning from #966, that you want to allow the possibilities. On the other hand, few servers are too strict that they don't accept other kinds of 'Content-Type' that they don't support.
If you still want to keep the behavior same, I would like to understand the reasoning behind a different implementation for OkHttpClient.