Re: [PATCH] git-cvsimport: add suport for CVS pserver method HTTP/1.x proxying

4 messages, 4 authors, 2016-08-11 · open the first message on its own page

Re: [PATCH] git-cvsimport: add suport for CVS pserver method HTTP/1.x proxying

From: Junio C Hamano <hidden>
Date: 2016-08-11 20:32:27

"Martin Langhoff (CatalystIT)" [off-list ref] writes:
Junio C Hamano wrote:
quoted
Except that this statement made me go "huh?" wondering what it
would do to the $filehandle to evaluate <$filehandle> in a void
context:

+			# Skip the empty line of the proxy server output
+			<$s>;
It's a perl idiom that will discard one line of the $filehandle. If we
are 200% certain that it is empty, then it's fine. OTOH, it may well
be a bug in the particular proxy implementation Iñaki is using -- I
don't know enough about CVS proxying to tell.
It is more about HTTP proxying and it is my understanding that
response to CONNECT method request has that empty line after the
successful (2xx) response line and zero or more response
headers.  The code is still wrong; it does not have a loop to
discard the potential response headers that come before the
empty line the code we are discussing discards.

By the way does anybody know where this behaviour is officially
specified?  Luotonen's draft-luotonen-web-proxy-tunneling-01.txt
is pretty clear about the empty line that comes after the
response headers, but that document being an internet-draft has
expired long time ago, but still seem to be quoted by others.
quoted
The "I/O Operators" section talks about evaluating <$s> in a
scalar context (i.e. "$rep = <$s>"), which we all know would
return a single line, and in list context, which swallows
This is in scalar context, and that's safe to rely on.
If it were in scalar context I would agree fully.  That
behaviour is documented.  But my point is that it is in void
context, and I did not find document specifying what should
happen.

Re: [PATCH] git-cvsimport: add suport for CVS pserver method HTTP/1.x proxying

From: Jeff King <hidden>
Date: 2016-08-11 19:17:22

On Fri, Nov 24, 2006 at 12:52:13PM +1300, Martin Langhoff wrote:
You are right. It should be something along the lines of

 # discard headers until first blank line
 while (<$s> ne '') {
     # nothing
 }

that is, assuming we can just ignore headers happily.
That code won't work; the value of a blank line will actually be "\n"
(or "\r\n"). So you probably want:

while (<$s>) {
  chomp; chomp;
  last unless $_;
}

or perhaps more readably:

while (<$s>) {
  last if $_ eq "\n" || $_ eq "\r\n";
}

Re: [PATCH] git-cvsimport: add suport for CVS pserver method HTTP/1.x proxying

From: Martin Langhoff <hidden>
Date: 2016-08-11 19:37:18

On 11/24/06, Junio C Hamano [off-list ref] wrote:
It is more about HTTP proxying and it is my understanding that
response to CONNECT method request has that empty line after the
successful (2xx) response line and zero or more response
headers.  The code is still wrong; it does not have a loop to
discard the potential response headers that come before the
empty line the code we are discussing discards.
You are right. It should be something along the lines of

  # discard headers until first blank line
  while (<$s> ne '') {
      # nothing
  }

that is, assuming we can just ignore headers happily.

cheers,


Re: [PATCH] git-cvsimport: add suport for CVS pserver method HTTP/1.x proxying

From: Martin Langhoff (CatalystIT) <hidden>
Date: 2016-08-11 20:44:42

Junio C Hamano wrote:
"Martin Langhoff (CatalystIT)" [off-list ref] writes:
quoted
This is in scalar context, and that's safe to rely on.

If it were in scalar context I would agree fully.  That
behaviour is documented.  But my point is that it is in void
context, and I did not find document specifying what should
happen.
Sorry! What I meant to say is: void context is always equivalent to 
scalar context.

cheers,


martin
-- 
-----------------------------------------------------------------------
Martin @ Catalyst .Net .NZ  Ltd, PO Box 11-053, Manners St,  Wellington
WEB: http://catalyst.net.nz/           PHYS: Level 2, 150-154 Willis St
OFFICE: +64(4)916-7224                              MOB: +64(21)364-017
       Make things as simple as possible, but no simpler - Einstein
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help