summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.http.test/tst
Commit message (Collapse)AuthorAgeFilesLines
* Handle SSL handshake failures in TransportHttpThomas Wolf2017-09-131-13/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a https connection could not be established because the SSL handshake was unsuccessful, TransportHttp would unconditionally throw a TransportException. Other https clients like web browsers or also some SVN clients handle this more gracefully. If there's a problem with the server certificate, they inform the user and give him a possibility to connect to the server all the same. In git, this would correspond to dynamically setting http.sslVerify to false for the server. Implement this using the CredentialsProvider to inform and ask the user. We offer three choices: 1. skip SSL verification for the current git operation, or 2. skip SSL verification for the server always from now on for requests originating from the current repository, or 3. always skip SSL verification for the server from now on. For (1), we just suppress SSL verification for the current instance of TransportHttp. For (2), we store a http.<uri>.sslVerify = false setting for the original URI in the repo config. For (3), we store the http.<uri>.sslVerify setting in the git user config. Adapt the SmartClientSmartServerSslTest such that it uses this mechanism instead of setting http.sslVerify up front. Improve SimpleHttpServer to enable setting it up also with HTTPS support in anticipation of an EGit SWTbot UI test verifying that cloning via HTTPS from a server that has a certificate that doesn't validate pops up the correct dialog, and that cloning subsequently proceeds successfully if the user decides to skip SSL verification. Bug: 374703 Change-Id: Ie1abada9a3d389ad4d8d52c2d5265d2764e3fb0e Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Support http.<url>.* configsThomas Wolf2017-09-101-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Git has a rather elaborate mechanism to specify HTTP configuration options per URL, based on pattern matching the URL against "http" subsection names.[1] The URLs used for this matching are always the original URLs; redirected URLs do not participate. * Scheme and host must match exactly case-insensitively. * An optional user name must match exactly. * Ports must match exactly after default ports have been filled in. * The path of a subsection, if any, must match a segment prefix of the path of the URL. * Matches with user name take precedence over equal-length path matches without, but longer path matches are preferred over shorter matches with user name. Implement this for JGit. Factor out the HttpConfig from TransportHttp and implement the matching and override mechanism. The set of supported settings is still the same; JGit currently supports only followRedirects, postBuffer, and sslVerify, plus the JGit-specific maxRedirects key. Add tests for path normalization and prefix matching only on segment separators, and use the new mechanism in SmartClientSmartServerSslTest to disable sslVerify selectively for only the test server URLs. Compare also bug 374703 and bug 465492. With this commit it would be possible to set sslVerify to false for only the git server using a self-signed certificate instead of having to switch it off globally via http.sslVerify. [1] https://git-scm.com/docs/git-config Change-Id: I42a3c2399cb937cd7884116a2a32fcaa7a418fcb Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Cleanup: message reporting for HTTP redirect handlingThomas Wolf2017-08-231-4/+4
| | | | | | | | | | | | | | | | | | The addition of "tooManyRedirects" in commit 7ac1bfc ("Do authentication re-tries on HTTP POST") was an error I didn't catch after rebasing that change. That message had been renamed in the earlier commit e17bfc9 ("Add support to follow HTTP redirects") to "redirectLimitExceeded". Also make sure we always use the TransportException(URIish, ...) constructor; it'll prefix the message given with the sanitized URI. Change messages to remove the explicit mention of that URI inside the message. Adapt tests that check the expected exception message text. For the info logging of redirects, remove a potentially present password component in the URI to avoid leaking it into the log. Change-Id: I517112404757a9a947e92aaace743c6541dce6aa Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Do authentication re-tries on HTTP POSTThomas Wolf2017-08-221-9/+252
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is at least one git server out there (GOGS) that does not require authentication on the initial GET for info/refs?service=git-receive-pack but that _does_ require authentication for the subsequent POST to actually do the push. This occurs on GOGS with public repositories; for private repositories it wants authentication up front. Handle this behavior by adding 401 handling to our POST request. Note that this is suboptimal; we'll re-send the push data at least twice if an authentication failure on POST occurs. It would be much better if the server required authentication up-front in the GET request. Added authentication unit tests (using BASIC auth) to the SmartClientSmartServerTest: - clone with authentication - clone with authentication but lacking CredentialsProvider - clone with authentication and wrong password - clone with authentication after redirect - clone with authentication only on POST, but not on GET Also tested manually in the wild using repositories at try.gogs.io. That server offers only BASIC auth, so the other paths (DIGEST, NEGOTIATE, fall back from DIGEST to BASIC) are untested and I have no way to test them. * public repository: GET unauthenticated, POST authenticated Also tested after clearing the credentials and then entering a wrong password: correctly asks three times during the HTTP POST for user name and password, then gives up. * private repository: authentication already on GET; then gets applied correctly initially to the POST request, which succeeds. Also fix the authentication to use the credentials for the redirected URI if redirects had occurred. We must not present the credentials for the original URI in that case. Consider a malicious redirect A->B: this would allow server B to harvest the user credentials for server A. The unit test for authentication after a redirect also tests for this. Bug: 513043 Change-Id: I97ee5058569efa1545a6c6f6edfd2b357c40592a Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Add support to follow HTTP redirectsThomas Wolf2017-08-173-62/+550
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git-core follows HTTP redirects so JGit should also provide this. Implement config setting http.followRedirects with possible values "false" (= never), "true" (= always), and "initial" (only on GET, but not on POST).[1] We must do our own redirect handling and cannot rely on the support that the underlying real connection may offer. At least the JDK's HttpURLConnection has two features that get in the way: * it does not allow cross-protocol redirects and thus fails on http->https redirects (for instance, on Github). * it translates a redirect after a POST to a GET unless the system property "http.strictPostRedirect" is set to true. We don't want to manipulate that system setting nor require it. Additionally, git has its own rules about what redirects it accepts;[2] for instance, it does not allow a redirect that adds query arguments. We handle response codes 301, 302, 303, and 307 as per RFC 2616.[3] On POST we do not handle 303, and we follow redirects only if http.followRedirects == true. Redirects are followed only a certain number of times. There are two ways to control that limit: * by default, the limit is given by the http.maxRedirects system property that is also used by the JDK. If the system property is not set, the default is 5. (This is much lower than the JDK default of 20, but I don't see the value of following so many redirects.) * this can be overwritten by a http.maxRedirects git config setting. The JGit http.* git config settings are currently all global; JGit has no support yet for URI-specific settings "http.<pattern>.name". Adding support for that is well beyond the scope of this change. Like git-core, we log every redirect attempt (LOG.info) so that users may know about the redirection having occurred. Extends the test framework to configure an AppServer with HTTPS support so that we can test cloning via HTTPS and redirections involving HTTPS. [1] https://git-scm.com/docs/git-config [2] https://kernel.googlesource.com/pub/scm/git/git/+/6628eb41db5189c0cdfdced6d8697e7c813c5f0f [3] https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html CQ: 13987 Bug: 465167 Change-Id: I86518cb76842f7d326b51f8715e3bbf8ada89859 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com> Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Enable and fix warnings about redundant specification of type argumentsDavid Pursehouse2017-02-205-11/+11
| | | | | | | | | | Since the introduction of generic type parameter inference in Java 7, it's not necessary to explicitly specify the type of generic parameters. Enable the warning in Eclipse, and fix all occurrences. Change-Id: I9158caf1beca5e4980b6240ac401f3868520aad0 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* Fix bad test fix from 0bff481 "Limit receive commands"Shawn Pearce2017-02-201-1/+1
| | | | | | | | | | | | | | | | | In 0bff481d45db74db81a3b1b86f7401443a60d970 to accurately use the two limits it was necessary to move the LimitedInputStream out of the PacketLineIn and further down to the PackParser. Unfortuantely this didn't survive review, as a buggy test failed and the "fix" was to drop this part of the code. The maxPackSizeLimit should apply to the pack stream, not the pkt-line framing used to send commands to control the ReceivePack instance. The commands are controlled using a different limit. The failing test allowed too many bytes in the pack and was only failing because it was including the command framing. The correct fix for the test was simply to drop the limit lower, to more closely match the actual pack size. Change-Id: I47d3885b9d7d527e153df7ac9c62fc2865ceecf4
* Enable and fix 'Should be tagged with @Override' warningDavid Pursehouse2017-02-1914-0/+33
| | | | | | | | | | | | | | | | | | | | | | | Set missingOverrideAnnotation=warning in Eclipse compiler preferences which enables the warning: The method <method> of type <type> should be tagged with @Override since it actually overrides a superclass method Justification for this warning is described in: http://stackoverflow.com/a/94411/381622 Enabling this causes in excess of 1000 warnings across the entire code-base. They are very easy to fix automatically with Eclipse's "Quick Fix" tool. Fix all of them except 2 which cause compilation failure when the project is built with mvn; add TODO comments on those for further investigation. Change-Id: I5772061041fd361fe93137fd8b0ad356e748a29c Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* Update Jetty to 9.4.1.v20170120Matthias Sohn2017-02-192-4/+4
| | | | | | | | | | | MappedLoginService is no longer available in Jetty 9.4 therefore base TestLoginService on AbstractLoginService. Apparently Jetty now uses slf4j hence adapt RecordingLogger accordingly so we can log error messages containing slf4j style formatting anchors "{}". Change-Id: Ibb36aba8782882936849b6102001a88b699bb65c Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Follow redirects in transportBo Zhang2017-02-021-13/+117
| | | | | | Bug: 465167 Change-Id: I6da19c8106201c2a1ac69002bd633b7387f25d96 Signed-off-by: Bo Zhang <zhangbodut@gmail.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Organize importsDavid Pursehouse2016-11-141-2/+2
| | | | | Change-Id: I7c545d06b1bced678c020fab9af1382bc4416b6e Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* Fix assertion in SmartClientSmartServerTest.testPush_CreateBranch()Matthias Sohn2016-07-071-1/+1
| | | | | | This assertion only defined a message but didn't assert anything. Change-Id: I0914642b64b69dc4e3ec24acbf8052f9171613d8 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Fix Buck build broken by 4812fda.Mike Edgar2016-04-141-52/+0
| | | | | | | | Creates a source directory under org.eclipse.jgit.http.test for the new support class. Signed-off-by: Michael Edgar <adgar@google.com> Change-Id: Ie49492c2bbe5c1db96ceb0dc06fa7cb9f927431a
* Make UploadPack observe exceptions reading refsMike Edgar2016-04-142-12/+124
| | | | | | | | | | | | | Now if refs are unreadable when serving an upload pack the handler will fail due to the actual underlying failure. Previously all wants would be rejected as invalid because Repository.getAllRefs() returned an empty map. Testing this required a new subclass of InMemoryRepository so that an IOException could be injected at the correct time. Signed-off-by: Michael Edgar <adgar@google.com> Change-Id: Iac708b1db9d0ccce08c4ef5ace599ea0b57afdc0
* smart HTTP server: Pass along "want X not valid" to clientShawn Pearce2016-02-161-0/+22
| | | | | | | | | | | | | If the client sends a SHA-1 that the server does not recognize echo this back to the client with an explicit error message instead of the generic "internal server error". This was always the intent of the implementation but it was being dropped on smart HTTP due to the UploadPackServlet catching the PackProtocolException, discarding the buffered message UploadPack meant to send, and sending along a generic message instead. Change-Id: I8d96b064ec655aef64ac2ef3e01853625af32cd1
* Suppress "unchecked cast" warnings related to UploadPackFactory.DISABLEDDavid Pursehouse2016-02-152-0/+2
| | | | | Change-Id: Id74694e18fec326df2b04eb796b46ccc6484b23f Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
* Transport: Implement AutoCloseableShawn Pearce2016-01-193-151/+50
| | | | | | | | After creating a Transport instance callers should always call its close() method. Use AutoCloseable to document this idiom and allow use of try-with-resources. Change-Id: I0c6ff3e39ebecdd7a028dbcae1856a818937b186
* GitServletResponseTest: Fix testObjectCheckerExceptionShawn Pearce2016-01-061-2/+4
| | | | | | | | The recent ObjectChecker changes to pass in AnyObjectId as part of the checkCommit method signature meant the override here was no longer throwing an exception as expected. Change-Id: I0383018b48426e25a0bc562387e8cd73cbe13129
* Ensure all http tests are run and fix broken testsMatthias Sohn2016-01-021-3/+4
| | | | | | | | | | HttpClientTests were broken. This wasn't discovered since maven-surefire-plugin's by default only executes test classes matching **/*Test.java. Fix this by also including **/*.Tests.java and fix the failing tests. Change-Id: I487a30fb333de993a9f8d8fff491d3b0e7fb02cc Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Repository: Introduce exactRef and findRef, deprecate getRefJonathan Nieder2015-11-254-15/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The Repository class provides only one method to look up a ref by name, getRef. If I request refs/heads/master and that ref does not exist, getRef will look further in the search path: ref/refs/heads/master refs/heads/refs/heads/master refs/remotes/refs/heads/master This behavior is counterintuitive, needlessly inexpensive, and usually not what the caller expects. Allow callers to specify whether to use the search path by providing two separate methods: - exactRef, which looks up a ref when its exact name is known - findRef, which looks for a ref along the search path For backward compatibility, keep getRef as a deprecated synonym for findRef. This change introduces findRef and exactRef but does not update callers outside tests to use them yet. Change-Id: I35375d942baeb3ded15520388f8ebb9c0cc86f8c Signed-off-by: Jonathan Nieder <jrn@google.com>
* Fix that exceptions in ReceivePack cause Invalid Channel 101 exceptionsChristian Halstrick2015-05-271-0/+295
| | | | | | | | | | | | | When during a PushOperation the server hits an exception different from UnpackException the JGit server behaved wrong. That kind of exceptions are handled so late that the connection is already released and the information whether to talk sideband to the client is lost. In detail: ReceivePack.receive() will call release() and that will reset the capabilities. But later on the stack in ReceivePackServlet.doPost() it is tried to send a response to client now with reset capabilities (no sideband!). Change-Id: I0a609acc6152ab43b47a93d712deb65bb1105f75 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Update to Jetty 9.2.10Matthias Sohn2015-05-105-10/+14
| | | | Change-Id: Iace29e6e99836019bb603ce06a08b91bada7c627 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Provide more details in exceptions thrown when packfile is invalidMatthias Sohn2015-02-171-1/+1
| | | | | | | | | Mention packfile path in exceptions thrown when we detect that a packfile is invalid and make excplicit that corrupt packs are removed from the pack list. Change-Id: I454ada5f8e69307d3f34d1c1b8f3cb87607ddf35 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Fix LocalDiskRepositoryTestCase to create correct type of reposChristian Halstrick2014-12-121-0/+5
| | | | | | | | | In one place LocalDiskRepositoryTestCase was ignoring the specification whether to create a bare or non-bare repository. Fix this and fix also one test which fails now because bare repos don't write reflogs by default. Change-Id: I4bcf8cf97c5b46e2f3919809eaa121a8d0e47010 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Add API to permit the setting of additional HTTP headersBogdan Gheorghe2014-04-251-0/+139
| | | | | Signed-off-by: Bogdan Gheorghe <gheorghe@ca.ibm.com> Change-Id: I1047f318bb5c63850f45ba85d73c97fe8bf70a6c
* Expose the received pack size in ReceivePackSaša Živkov2014-03-021-0/+165
| | | | | | | PostReceiveHooks can make use of this information to, for example, update a cached size of the Git repository. Change-Id: I2bf1200959a50531e2155a7609c96035ba45b10d Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Add an implementation for HttpConnection using Apache HttpClientChristian Halstrick2014-02-183-0/+63
| | | | | | | | | | | | | This change implements the http connection abstraction with the help of org.apache.http.client.HttpClient. The default implementation used by JGit is still the JDK HttpURLConnection. But now JGit users have the possibility to switch completely to org.apache.httpclient. The reason for this is that in certain (e.g. cloud) environments you are forced to use the org.apache classes. Change-Id: I0b357f23243ed13a014c79ba179fa327dfe318b2 Signed-off-by: Christian Halstrick <christian.halstrick@sap.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Use getPath() in FileResolverTestShawn Pearce2013-11-011-1/+1
| | | | | | | Necessary to get tests to pass when running under Buck. Has no impact on Maven based invocation of tests. Change-Id: I437114863df0bac346c94ef13796def47333d916
* Fix NPE in openFetch on Transport without local repositoryRobin Stocker2013-07-211-0/+16
| | | | | | | | | | | Setting the walk and other fields to null will result in NPEs when the user e.g. calls fetch on the connection, but at least the advertised refs can be read like that without having a local repository. Bug: 413389 Change-Id: I39c8363e81a1c7e6cb3412ba88542ead669e69ed Signed-off-by: Robin Stocker <robin@nibor.org> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
* Fix tests for OS X when the tmpdir is the default /tmpRobin Rosenberg2013-06-163-3/+11
| | | | | | | | | | | /tmp is a symbolic link and some tests break when the path gets canonicalized by JGit or Jetty. Allow Jetty to serve symlinks by setting init parameter "aliases" to true [1]. [1] http://wiki.eclipse.org/Jetty/Howto/How_to_serve_symbolically_linked_files Change-Id: I45359a40435e8a33def6e0bb6784b4d8637793ac Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Make the Reflog a public API againRobin Rosenberg2013-04-261-2/+2
| | | | Change-Id: I8ced7098da5b345fd9af2fdfafd1ef6a44ccee0d
* Remove some unnecessary dependencies on FileRepostoryRobin Rosenberg2013-04-187-35/+28
| | | | | Change-Id: Ib6ee3a2874a7e2240aa68f4ac32d00c4d1fab5ae Signed-off-by: Chris Aniszczyk <zx@twitter.com>
* Allow users to show server messages while pushingAndré Dietisheim2013-03-211-0/+38
| | | | | | | | | | | | Allow users to provide their OutputStream (via Transport# push(monitor, refUpdates, out)) so that server messages can be written to it (in SideBandInputStream) while they're coming in. CQ: 7065 Bug: 398404 Change-Id: I670782784b38702d52bca98203909aca0496d1c0 Signed-off-by: Andre Dietisheim <andre.dietisheim@gmail.com> Signed-off-by: Chris Aniszczyk <zx@twitter.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* JGit 3.0: move internal classes into an internal subpackageShawn Pearce2013-03-187-9/+9
| | | | | | | | This breaks all existing callers once. Applications are not supposed to build against the internal storage API unless they can accept API churn and make necessary updates as versions change. Change-Id: I2ab1327c202ef2003565e1b0770a583970e432e9
* Declare essentially static methods as staticRobin Rosenberg2012-12-272-2/+2
| | | | Change-Id: I83ca25fb569c0dbc36eb374d5437fcf2b65a6f68
* Add type argumente to some raw reclarationRobin Rosenberg2012-12-276-16/+32
| | | | Change-Id: Ief195fb5c55f75172f0428fdac8c8874292ae566
* Work around smart HTTP bugs in C GitShawn O. Pearce2012-06-271-0/+85
| | | | | | | | | | | | | | | I have unfortunately introduced a few bugs in the native Git client over the years. 1.7.5 is unable to send chunked requests correctly, resulting in corrupt data at the server. Ban this client whenever it uses chunked encoding with an error message. Prior to some more recent versions, git push over HTTP failed to report status information and error messages due to a race within the client and its helper process. Check for these bad versions and send errors as messages before the status report, enabling users to see the failures on their terminal. Change-Id: Ic62d6591cbd851d21dbb3e9b023d655eaecb0624
* Add simple tests for RegexPipelineDave Borowitz2012-06-081-0/+209
| | | | Change-Id: Ie800c55702ea9724b393be0a8b36e0e4da1a6e0d
* Revert Jetty from 8.1.3.v20120416 to 7.6.0.v20120127Matthias Sohn2012-06-031-5/+3
| | | | | | | | | | | This reverts commit 24a0f47e32ab7cdf20c2201d7100599ea057f8a3 and updates JGit dependencies to use the latest available Jetty 7.x release. We can't use Jetty 8.x since it depends on Servlet API 3.0 which requires Java 6 but JGit still wants to support Java 5. Use one of the target platforms defined in Ibf67a6d3539fa0708a3e5dbe44fb899c56fbd8ed to work with that in Eclipse. Change-Id: I343273d994dc7b6e0287c604e5926ff77d5b585b Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Update Jetty to 8.1.3.v20120416Matthias Sohn2012-05-232-12/+27
| | | | | | | | Jetty 8.1.3 comes with Juno M7 and this version can be installed from http://download.eclipse.org/jetty/updates/jetty-bundles-8.x/8.1.3.v20120416/ Change-Id: Ifc4bfbb3efbab0f5bfbde74f0b2ddc5a2f9ee6a5 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Move NLS test for HttpServerText to http.testShawn O. Pearce2012-05-221-0/+60
| | | | | | | This never should have been in the core library test suite, as that test suite never should depend upon the HTTP server module. Change-Id: Ie0528c4d1c755823303d138e327a3a2f4caccc32
* Move JGitText to an internal packageRobin Rosenberg2012-03-123-3/+3
| | | | Change-Id: I763590a45d75f00a09097ab6f89581a3bbd3c797
* Ensure all smart HTTP errors are sent to clientsShawn O. Pearce2011-12-011-0/+188
| | | | | | | | | | | | | | | | | Error messages are typically short, below the 32 KiB in-memory buffer size of the SmartOutputStream. When an error is queued up for sending to a client and an exception is thrown up into the servlet handler we discarded the message and sent nothing to the client, as the messages were stuck inside of the SmartOutputStream buffer. Hoist the creation of the output stream above the invocation of try block of the service, and use close() in the few catch blocks that assume there are buffered messages ready for transmission. This will ensure errors from unpacking a stream in ReceivePack are sent off to a client correctly, as previously these were causing no status report to arrive at the client side as the data was stuck in the buffer. Change-Id: I5534b560697731121f48979ae077aa7c95b8e39c
* Fix HTTP unit testsShawn O. Pearce2011-11-301-2/+1
| | | | | | | | I modified the way errors are returned, and this particular test is now getting a different access denied response. The new text happens to be what I intended to have here, so update the test. Change-Id: I53f8410ca0a52755d80473cd5cbcdb4d8502febf
* Refactor out ReflogEntryChris Aniszczyk2011-06-201-1/+2
| | | | | | | | It's useful to have ReflogEntry refactored out so it can be used by clients via the JGit API. Change-Id: I03044df9af9f9547777545b7c9b93bdf5f8b7cb5 Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
* Merge branch 'stable-0.12'Shawn O. Pearce2011-04-211-3/+64
|\ | | | | | | | | * stable-0.12: Implement the no-done capability
| * Implement the no-done capabilityShawn O. Pearce2011-04-211-3/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Smart HTTP clients may request both multi_ack_detailed and no-done in the same request to prevent the client from needing to send a "done" line to the server in response to a server's "ACK %s ready". For smart HTTP, this can save 1 full HTTP RPC in the fetch exchange, improving overall latency when incrementally updating a client that has not diverged very far from the remote repository. Unfortuantely this capability cannot be enabled for the traditional bi-directional connections. multi_ack_detailed has the client sending more "have" lines at the same time that the server is creating the "ACK %s ready" and writing out the PACK stream, resulting in some race conditions and/or deadlock, depending on how the pipe buffers are implemented. For very small updates, a server might actually be able to send "ACK %s ready", then the PACK, and disconnect before the client even finishes sending its first batch of "have" lines. This may cause the client to fail with a broken pipe exception. To avoid all of these potential problems, "no-done" is restricted only to the smart HTTP variant of the protocol. Change-Id: Ie0d0a39320202bc096fec2e97cb58e9efd061b2d Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* | Enabled unit tests in HttpClientTestsChristian Halstrick2011-04-211-0/+13
|/ | | | | Change-Id: I92ae117f1dcfc569e27c66c191e090a60fbe2bb6 Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
* smart HTTP: Return errors inside payloadShawn O. Pearce2011-04-011-0/+32
| | | | | | | | | | | | | | | | When the client is clearly making a smart HTTP request to our smart HTTP server, return any errors like RepositoryNotFoundException or ServiceNotEnabledException inside of the payload as a Git level ERR message, rather than an HTTP error code. This prevents the C Git command line client from retrying a failed "$URL/info/refs?service=git-upload-pack" request without the smart service URL, only to fail again with "403 Forbidden" when the dumb as-is service has been disabled by the server configuration, or is unavailable because the repository is not on the local filesystem. Change-Id: I57e8756d5026e885e0ca615979bfcd729703be6c Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* smart-http: Fix recognition of gzip encodingShawn O. Pearce2011-02-151-0/+64
| | | | | | | | | | | | | | | | | | | | | | Some clients coming through proxies may advertise a different Accept-Encoding, for example "Accept-Encoding: gzip(proxy)". Matching by substring causes us to identify this as a false positive; that the client understands gzip encoding and will inflate the response before reading it. In this particular case however it doesn't. Its the reverse proxy server in front of JGit letting us know the proxy<->JGit link can be gzip compressed, while the client<->proxy part of the link is not: client <-- no gzip --> proxy <-- gzip --> JGit Use a more standard method of parsing by splitting the value into tokens, and only using gzip if one of the tokens is exactly the string "gzip". Add a unit test to make sure this isn't broken in the future. Change-Id: I30cda8a6d11ad235b56457adf54a2d27095d964e Signed-off-by: Shawn O. Pearce <spearce@spearce.org>