-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chunk streaming request bodies only #157
Merged
Merged
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e1787f1
fix
mgyucht e51c332
Fix logging setup for example
mgyucht 3122cb0
move SimpleHttpServer to tests
mgyucht ad725d0
Refactor FixtureServer
mgyucht 5ba026e
fmt
mgyucht 8489050
commet
mgyucht 12f6c11
fix test
mgyucht 62dbaef
fmt
mgyucht 9f8a0c2
address comments
mgyucht 4f2531c
fmt
mgyucht File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 0 additions & 108 deletions
108
databricks-sdk-java/src/main/java/com/databricks/sdk/core/SimpleHttpServer.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,18 +14,24 @@ | |
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
import com.databricks.sdk.mixin.ClustersExt; | ||
import org.apache.commons.io.IOUtils; | ||
import org.apache.http.HttpEntity; | ||
import org.apache.http.NameValuePair; | ||
import org.apache.http.StatusLine; | ||
import org.apache.http.client.config.RequestConfig; | ||
import org.apache.http.client.methods.*; | ||
import org.apache.http.entity.InputStreamEntity; | ||
import org.apache.http.entity.StringEntity; | ||
import org.apache.http.impl.client.CloseableHttpClient; | ||
import org.apache.http.impl.client.HttpClientBuilder; | ||
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class CommonsHttpClient implements HttpClient { | ||
private static final Logger LOG = LoggerFactory.getLogger(ClustersExt.class); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not ClustersExt, but CommonsHttpClient |
||
private final PoolingHttpClientConnectionManager connectionManager = | ||
new PoolingHttpClientConnectionManager(); | ||
private final CloseableHttpClient hc; | ||
|
@@ -117,18 +123,24 @@ private HttpUriRequest transformRequest(Request in) { | |
case Request.DELETE: | ||
return new HttpDelete(in.getUri()); | ||
case Request.POST: | ||
return withEntity(new HttpPost(in.getUri()), in.getBody()); | ||
return withEntity(new HttpPost(in.getUri()), in); | ||
case Request.PUT: | ||
return withEntity(new HttpPut(in.getUri()), in.getBody()); | ||
return withEntity(new HttpPut(in.getUri()), in); | ||
case Request.PATCH: | ||
return withEntity(new HttpPatch(in.getUri()), in.getBody()); | ||
return withEntity(new HttpPatch(in.getUri()), in); | ||
default: | ||
throw new IllegalArgumentException("Unknown method: " + in.getMethod()); | ||
} | ||
} | ||
|
||
private HttpRequestBase withEntity(HttpEntityEnclosingRequestBase request, InputStream body) { | ||
request.setEntity(new InputStreamEntity(body)); | ||
private HttpRequestBase withEntity(HttpEntityEnclosingRequestBase request, Request in) { | ||
if (in.isBodyString()) { | ||
request.setEntity(new StringEntity(in.getBodyString(), StandardCharsets.UTF_8)); | ||
} else if (in.isBodyStreaming()) { | ||
request.setEntity(new InputStreamEntity(in.getBodyStream())); | ||
} else { | ||
LOG.warn("withEntity called with a request with no body, so no request entity will be set. URI: {}", in.getUri()); | ||
} | ||
return request; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This used to be
<InputStream>
; I've changed it to(streamed body)
in the debug log.