use of com.google.api.client.util.StreamingContent in project scout.rt by eclipse.
the class ApacheHttpRequest method execute.
@Override
public LowLevelHttpResponse execute() throws IOException {
final StreamingContent streamingContent = getStreamingContent();
if (streamingContent != null) {
if (!(m_request instanceof HttpEntityEnclosingRequest)) {
throw new ProcessingException("This request {} does not support content.", m_request);
}
AbstractHttpEntity entity = new AbstractHttpEntity() {
@Override
public void writeTo(OutputStream outstream) throws IOException {
streamingContent.writeTo(outstream);
}
@Override
public boolean isStreaming() {
return true;
}
@Override
public boolean isRepeatable() {
if (streamingContent instanceof HttpContent) {
return ((HttpContent) streamingContent).retrySupported();
}
return false;
}
@Override
public long getContentLength() {
return ApacheHttpRequest.this.getContentLength();
}
@Override
public InputStream getContent() throws IOException {
throw new UnsupportedOperationException("Streaming entity cannot be represented as an input stream.");
}
};
((HttpEntityEnclosingRequest) m_request).setEntity(entity);
entity.setContentEncoding(getContentEncoding());
entity.setContentType(getContentType());
}
return createResponseInternal();
}
Aggregations