Apache client http5 override body & content-length problem

92 Views Asked by At

Prior to http5, i use HttpRequestInterceptor to override Entity, to sign request, ect ... with apache thrif calls (to evict override Thttpclient from libthrift)

With http5, interceptor have a new argument on interceptor method, EntityDetails, and it use on org.apache.hc.core5.http.protocol.RequestContent interceptor to set content-length header

But, entity has been overrided before ... and entity argument is now obsolete and all my request are now send with bad content-length.

Is this a bug ? Or is there an other method with http5 to override entity/body ? (here sign request with certificate)

** workaround with a last interceptor to override content-length is ok

1

There are 1 best solutions below

0
ok2c On

Generally one ought not //self-censored// around with Cotnent-Length and let HttpClient generate it based on the entity details. If one needs to modify the message body one should be using a custom execution interceptor instead. This example may serve as a reasonable starting point