'Jersey HTTP client content-length header
I have a kotlin classthat tryies to upload a jar file to AWS codeartifact.
val upload = client.target(to)
.request()
.header("X-Checksum-Sha1", sha1)
.header("Authorization", "Basic " + encodedAuth.toString(Charsets.UTF_8))
//.header("Content-Length", jarAsInputStream.available())
.put(Entity.entity(jarAsInputStream, MediaType.APPLICATION_OCTET_STREAM))
if (upload.statusInfo.family != Response.Status.Family.SUCCESSFUL)
throw RuntimeException("Upload failed, status=${upload.status} from=$from to=$to")
When i use it so as it is in the code snippet, the AWS codeartifact service responds with a 411
status 'content-length required'.
So i add the line (which is commented in the above snippet) .header("Content-Length", jarAsInputStream.available())
and the Jersey client throws an error Content-Length header already present
Has any of you had a similar issue? if so, how did you solve it?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|