Skip to content

How to detect org.apache.http.HttpEntity #4736

Answered by tom08zehn
tom08zehn asked this question in Q&A
Discussion options

You must be logged in to vote

I correct myself: body instanceof org.apache.http.HttpEntity does work perfectly well in my case where I do:

org.apache.http.entity.mime.MultipartEntityBuilder.create()
    // ...
    .build();

... what returns type HttpEntity.

I'd like to share my final solution:

var entity = body instanceof org.apache.http.HttpEntity ? body : new StringEntity(body, charset)
httpRequest.setEntity(entity);

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by tom08zehn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant