public class EmptyContent extends Object implements HttpContent
HttpRequest.execute()
to add the header
Content-Length: 0
.
Note that there is no Content-Length
header if the HTTP request content is null
. However, when making a request like PUT or POST without a Content-Length
header,
some servers may respond with a 411 Length Required
error. Specifying the Content-Length: 0
header may work around that problem.
Constructor and Description |
---|
EmptyContent() |
Modifier and Type | Method and Description |
---|---|
long |
getLength()
Returns the content length or less than zero if not known.
|
String |
getType()
Returns the content type or
null for none. |
boolean |
retrySupported()
Returns whether or not retry is supported on this content type.
|
void |
writeTo(OutputStream out)
Writes the byte content to the given output stream.
|
public long getLength() throws IOException
HttpContent
getLength
in interface HttpContent
IOException
public String getType()
HttpContent
null
for none.getType
in interface HttpContent
public void writeTo(OutputStream out) throws IOException
StreamingContent
Implementations must not close the output stream, and instead should flush the output stream. Some callers may assume that the output stream has not been closed, and will fail to work if it has been closed.
writeTo
in interface HttpContent
writeTo
in interface StreamingContent
out
- output streamIOException
public boolean retrySupported()
HttpContent
retrySupported
in interface HttpContent
Copyright © 2011–2022 Google. All rights reserved.