Commit Graph

22 Commits

Author SHA1 Message Date
Matt Harbison
276f97c4dd test-http-proxy: redirect proxy stdout to /dev/null
This output hasn't been getting flushed, but would alter the log if it ever grew
large enough.  See b6dc6aa294f4.
2017-06-19 21:53:54 -04:00
Matt Harbison
602d34124b tinyproxy: explicitly flush logged messages
On Windows, output streams are buffered when redirected to a file, and
TerminateProcess() apparently doesn't trigger a flush.  This left
test-http-proxy.t missing part of the last line when it cat'd proxy.log[1].

Flushing stderr is all that is needed (on py27 anyway).  I originally flushed
stdout too, but that added additional output to the log:

     $ cat proxy.log
  +  Accept: $LOCALIP (localhost)\r (esc)
  +  Serving HTTP on 0.0.0.0 port 20810 ...\r (esc)
  +       connect to localhost:$HGPORT\r (esc)
     * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob)
  +       bye\r (esc)
  +       connect to localhost:$HGPORT\r (esc)
     * - - [*] "GET http://localhost:$HGPORT/?cmd=branchmap HTTP/1.1" - - x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
  +       bye\r (esc)
  +       connect to localhost:$HGPORT\r (esc)
     * - - [*] "GET http://localhost:$HGPORT/?cmd=stream_out HTTP/1.1" - - x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
  +       bye\r (esc)
  +       connect to localhost:$HGPORT\r (esc)
 ...

[1] https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-April/096987.html
2017-06-18 21:31:53 -04:00
Gregory Szorc
92e8a3e848 tests: use urlreq in tinyproxy.py
This is our last consumer of util.urlparse.
2017-03-21 22:45:02 -07:00
Jun Wu
2e482ea3e3 tinyproxy: use IPv6 if HGIPV6 is set to 1
This patch makes tinyproxy.py work in IPv6 mode if HGIPV6 is set to 1.

This will make test-http-proxy.t pass on IPv6 machines.
2017-02-15 22:53:45 -08:00
Pulkit Goyal
6b3bc52b40 py3: conditionalize BaseHTTPServer, SimpleHTTPServer and CGIHTTPServer import
The BaseHTTPServer, SimpleHTTPServer and CGIHTTPServer has been merged into
http.server in python 3. All of them has been merged as util.httpserver to use
in both python 2 and 3. This patch adds a regex to check-code to warn against
the use of BaseHTTPServer. Moreover this patch also includes updates to lower
part of test-check-py3-compat.t which used to remain unchanged.
2016-07-13 23:38:29 +05:30
Pulkit Goyal
ad5a0af23f py3: re-implement the BaseHTTPServer.test() function
The function is changed in python 3. So the latest version of function is
re-implemented. One can look at https://hg.python.org/cpython/file/3.5/Lib/http/server.py#l1184
 and https://hg.python.org/cpython/file/2.7/Lib/BaseHTTPServer.py#l590 to see the change
2016-07-15 23:00:31 +05:30
Pulkit Goyal
38a359ce5c py3: conditionalize SocketServer import
The SocketServer is renamed to socketserver in python 3
2016-06-27 16:48:54 +05:30
Pulkit Goyal
5fcc6a2628 py3: conditionalize the urlparse import
The urlparse library is renamed to urllib.parse in python 3
2016-06-27 16:16:10 +05:30
Yuya Nishihara
9f89f6c82a tests: make tinyproxy.py not import sys.argv by name 2016-04-03 20:12:59 +09:00
Yuya Nishihara
a135a6b1fd tests: sort import lines in tinyproxy.py 2016-04-03 20:11:41 +09:00
Pulkit Goyal
9473cc11a7 tests: make tinyproxy.py use print_function 2016-03-28 01:57:44 +05:30
timeless
ebb1d48658 cleanup: remove superfluous space after space after equals (python) 2015-12-31 08:16:59 +00:00
Gregory Szorc
7a14eca3ba tests: use absolute_import in tinyproxy
Thus begins a series of adding absolute_import to a bunch of files for
Python 3 compatibility.
2015-12-06 22:20:08 -08:00
Gregory Szorc
5380dea2a7 global: mass rewrite to use modern exception syntax
Python 2.6 introduced the "except type as instance" syntax, replacing
the "except type, instance" syntax that came before. Python 3 dropped
support for the latter syntax. Since we no longer support Python 2.4 or
2.5, we have no need to continue supporting the "except type, instance".

This patch mass rewrites the exception syntax to be Python 2.6+ and
Python 3 compatible.

This patch was produced by running `2to3 -f except -w -n .`.
2015-06-23 22:20:08 -07:00
Mads Kiilerich
d04afd8fe1 tests: fix toctou race in tinyproxy.py (issue3795)
test-http-proxy.t sometimes failed with:
    File ".../tests/tinyproxy.py", line 110, in _read_write
      data = i.recv(8192)
  error: (104, 'Connection reset by peer')

This might have started showing up with 9eb533d10f1a ... but it has apparently
also been seen before. I don't see anything in 9eb533d10f1a that can explain
it. It seems to be a race in test, in the tinyproxy helper:

Tinyproxy found an incoming socket using select(). It would break the loop if
an error had been detected on the socket, but there was no error and it tried
to recv() from the socket. That failed - apparently because it had been reset
after select().

Errors in the recv() will now be caught and will break the loop like errors
detected by select() would.

(send() could also fail in a similar way ... but using the same solution there
and losing data we have read doesn't feel right.)
2013-01-31 19:13:13 +01:00
Brodie Rao
46ce54af4d cleanup: replace more naked excepts with more specific ones 2012-05-13 13:17:31 +02:00
Matt Mackall
18bf05f2aa tests: fix startup/shutdown races in test-https
tinyproxy now writes its own pid when it's ready to accept connections
2012-03-28 19:23:25 -05:00
Augie Fackler
dfe2a9638f tests: use getattr instead of hasattr 2011-07-25 16:37:18 -05:00
Martin Geisler
af8a35e078 check-code: flag 0/1 used as constant Boolean expression 2011-06-01 12:38:46 +02:00
Steven Brown
c1075f3880 httprepo: long arguments support (issue2126)
Send the command arguments in the HTTP headers. The command is still part
of the URL. If the server does not have the 'httpheader' capability, the
client will send the command arguments in the URL as it did previously.

Web servers typically allow more data to be placed within the headers than
in the URL, so this approach will:
- Avoid HTTP errors due to using a URL that is too large.
- Allow Mercurial to implement a more efficient wire protocol.

An alternate approach is to send the arguments as part of the request body.
This approach has been rejected because it requires the use of POST
requests, so it would break any existing configuration that relies on the
request type for authentication or caching.

Extensibility:
- The header size is provided by the server, which makes it possible to
  introduce an hgrc setting for it.
- The client ignores the capability value after the first comma, which
  allows more information to be included in the future.
2011-05-01 01:04:37 +08:00
Matt Mackall
8d99be19f0 many, many trivial check-code fixups 2010-01-25 00:05:27 -06:00
Vadim Gelfer
46bfa5a813 http: fix many problems with url parsing and auth. added proxy test.
problems fixed:

- https scheme handled properly for real and proxy urls.

- url of form "http://user:password@host:port/path" now ok.

- no-proxy check uses proper host names.
2006-05-22 15:42:49 -07:00