Mercurial > jhg
comparison src/org/tmatesoft/hg/internal/remote/HttpConnector.java @ 697:24f4efedc9d5
Respect the fact ssh and http protocols use different compression approach to sent changegroup data
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Tue, 06 Aug 2013 13:34:34 +0200 |
parents | 9859fcea475d |
children | 822f3a83ff57 |
comparison
equal
deleted
inserted
replaced
696:5b5d199e2eb3 | 697:24f4efedc9d5 |
---|---|
17 package org.tmatesoft.hg.internal.remote; | 17 package org.tmatesoft.hg.internal.remote; |
18 | 18 |
19 import static org.tmatesoft.hg.util.LogFacility.Severity.Info; | 19 import static org.tmatesoft.hg.util.LogFacility.Severity.Info; |
20 | 20 |
21 import java.io.BufferedReader; | 21 import java.io.BufferedReader; |
22 import java.io.ByteArrayInputStream; | |
22 import java.io.FilterOutputStream; | 23 import java.io.FilterOutputStream; |
23 import java.io.IOException; | 24 import java.io.IOException; |
24 import java.io.InputStream; | 25 import java.io.InputStream; |
25 import java.io.InputStreamReader; | 26 import java.io.InputStreamReader; |
26 import java.io.OutputStream; | 27 import java.io.OutputStream; |
28 import java.io.SequenceInputStream; | |
27 import java.net.HttpURLConnection; | 29 import java.net.HttpURLConnection; |
28 import java.net.MalformedURLException; | 30 import java.net.MalformedURLException; |
29 import java.net.URL; | 31 import java.net.URL; |
30 import java.net.URLConnection; | 32 import java.net.URLConnection; |
31 import java.security.cert.CertificateException; | 33 import java.security.cert.CertificateException; |
259 conn = setupConnection(u.openConnection()); | 261 conn = setupConnection(u.openConnection()); |
260 conn.connect(); | 262 conn.connect(); |
261 if (debug) { | 263 if (debug) { |
262 dumpResponseHeader(u); | 264 dumpResponseHeader(u); |
263 } | 265 } |
264 return conn.getInputStream(); | 266 InputStream cg = conn.getInputStream(); |
265 } catch (MalformedURLException ex) { // XXX in fact, this exception might be better to be re-thrown as RuntimeEx, | 267 InputStream prefix = new ByteArrayInputStream("HG10GZ".getBytes()); // didn't see any other that zip |
266 // as there's little user can do about this issue (URLs are constructed by our code) | 268 return new SequenceInputStream(prefix, cg); |
269 } catch (MalformedURLException ex) { | |
270 // although there's little user can do about this issue (URLs are constructed by our code) | |
271 // it's still better to throw it as checked exception than RT because url is likely malformed due to parameters | |
272 // and this may help user to understand the cause (and e.g. change them) | |
267 throw new HgRemoteConnectionException("Bad URL", ex).setRemoteCommand("changegroup").setServerInfo(getServerLocation()); | 273 throw new HgRemoteConnectionException("Bad URL", ex).setRemoteCommand("changegroup").setServerInfo(getServerLocation()); |
268 } catch (IOException ex) { | 274 } catch (IOException ex) { |
269 throw new HgRemoteConnectionException("Communication failure", ex).setRemoteCommand("changegroup").setServerInfo(getServerLocation()); | 275 throw new HgRemoteConnectionException("Communication failure", ex).setRemoteCommand("changegroup").setServerInfo(getServerLocation()); |
270 } | 276 } |
271 } | 277 } |