diff options
author | Thomas Wolf <thomas.wolf@paranor.ch> | 2019-08-11 22:37:48 +0200 |
---|---|---|
committer | Thomas Wolf <thomas.wolf@paranor.ch> | 2019-08-26 22:53:10 +0200 |
commit | 308bdb5d1b3a675f134dd5c038b29bfa1a671d19 (patch) | |
tree | b52fadca70e9c42d38bfef64d8681abd7bba32e3 /org.eclipse.jgit.http.apache/src | |
parent | cb208fb3ca130a2241bef3f3a33d54269d3a14ba (diff) | |
download | jgit-308bdb5d1b3a675f134dd5c038b29bfa1a671d19.tar.gz jgit-308bdb5d1b3a675f134dd5c038b29bfa1a671d19.zip |
Apache HTTP: run more tests
Factor out the test parameterization to use both connection factories
into a common super class and use it in more tests.
This made HttpClientTests.testV2HttpSubsequentResponse() fail for
Apache HTTP. The test used the pattern
- create POST connection
- setDoOutput(true)
- connect()
- write output stream
- get & read input stream
This pattern is never used in JGit, which actually calls connect() only
in one case in LFS, and that's on a HEAD request.
The above pattern works on JDK, but fails on Apache HTTP because with
Apache HTTP a connect() actually executes the full request including
writing the entity. To work with Apache HTTP, the pattern would need
to be
- create POST connection
- setDoOutput(true)
- write output stream
- connect()
- get & read input stream
which is fine for both. JDK connects implicitly in getOutputStream()
and treats the later explicit connect() as a no-op, and Apache works
because the entity is written when connect() is called.
Because JDK connects implicitly on getOutputStream(), the following
pattern also works with JDK:
- create POST connection
- setDoOutput(true)
- write output stream
- get & read input stream
Support this with Apache HTTP too: let getInputStream() execute
the request if it wasn't executed already.
Remove explicit connect() calls from test code, since JGit doesn't do
those either.
Change-Id: Ica038c00a7b8edcc01d5660d18e961146305b87f
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.jgit.http.apache/src')
-rw-r--r-- | org.eclipse.jgit.http.apache/src/org/eclipse/jgit/transport/http/apache/HttpClientConnection.java | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/org.eclipse.jgit.http.apache/src/org/eclipse/jgit/transport/http/apache/HttpClientConnection.java b/org.eclipse.jgit.http.apache/src/org/eclipse/jgit/transport/http/apache/HttpClientConnection.java index 4ac81a54df..f92c5df792 100644 --- a/org.eclipse.jgit.http.apache/src/org/eclipse/jgit/transport/http/apache/HttpClientConnection.java +++ b/org.eclipse.jgit.http.apache/src/org/eclipse/jgit/transport/http/apache/HttpClientConnection.java @@ -345,6 +345,7 @@ public class HttpClientConnection implements HttpConnection { /** {@inheritDoc} */ @Override public InputStream getInputStream() throws IOException { + execute(); return resp.getEntity().getContent(); } |