# HTTP push not respecting .netrc

5 messages from 2010-12-30 to 2011-01-27. Participants: David Borowitz, Tay Ray Chuan, Junio C Hamano.
Thread: https://gitlist.dev/t/26161

## David Borowitz, 2010-12-30 06:56

Subject: HTTP push not respecting .netrc
Message-ID: <AANLkTik84-zRwi+0dGGFoTUrj6Zr3bxO=fE9P_3MuZdZ@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTik84-zRwi%2B0dGGFoTUrj6Zr3bxO%3DfE9P_3MuZdZ%40mail.gmail.com

```
Hi all,

I'm trying to push to a smart HTTP remote using the following command line:
http_proxy=localhost:4242 git push -v http://xxxxx:25989/git/foo
+refs/heads/*:refs/heads/*
(The weird proxy and port are not under my control.)

The webserver should return 401 for unauthorized access, and indeed it does:
error: RPC failed; result=65, HTTP code = 401
(The rest of the error text from git push is not particularly useful,
but I'm not worried about that at the moment.)

Making a request manually with curl --netrc shows that the auth header
is being sent[1]. But sniffing the HTTP traffic from git shows that
the auth header is not sent[2].

I also tried various other things like aliasing xxxxx to 127.0.0.1 and
removing the proxy and port number, and specifying user@xxxxx in the
URL, and nothing I've done makes git send the necessary auth header.
(In the last case it does prompt for a password.)

Anyone have any other ideas? I could swear this was working a few
weeks ago, so I must be missing something simple.

[1]
$ http_proxy=localhost:4242 curl -vvn
http://xxxxx:25989/git/foo/info/refs?service=git-receive-pack
* About to connect() to proxy localhost port 4242 (#0)
*   Trying ::1... Connection refused
*   Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 4242 (#0)
* Server auth using Basic with user 'yyyyy'         <----
> GET http://xxxxx:25989/git/foo/info/refs?service=git-receive-pack HTTP/1.1
> Authorization: Basic zzzzzzzz          <----
> User-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15
> Host: xxxxx:25989
> Accept: */*
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 200 OK
...


[2]
GET http://xxxxx:25989/git/foo/info/refs?service=git-receive-pack HTTP/1.1
User-Agent: git/1.7.4.rc0
Host: xxxxx:25989
Accept: */*
Proxy-Connection: Keep-Alive
Pragma: no-cache

```

## Tay Ray Chuan, 2010-12-31 04:03

Subject: Re: HTTP push not respecting .netrc
Message-ID: <AANLkTi=4cE711TtqE0E-05s9Pk72C8OymNf_-5NhrfXS@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTi%3D4cE711TtqE0E-05s9Pk72C8OymNf_-5NhrfXS%40mail.gmail.com
In-Reply-To: <AANLkTik84-zRwi+0dGGFoTUrj6Zr3bxO=fE9P_3MuZdZ@mail.gmail.com>

```
On Thu, Dec 30, 2010 at 2:56 PM, David Borowitz <dave@bwitz.com> wrote:
> I'm trying to push to a smart HTTP remote using the following command line:
> http_proxy=localhost:4242 git push -v http://xxxxx:25989/git/foo
> +refs/heads/*:refs/heads/*
> (The weird proxy and port are not under my control.)
>
> The webserver should return 401 for unauthorized access, and indeed it does:
> error: RPC failed; result=65, HTTP code = 401
> (The rest of the error text from git push is not particularly useful,
> but I'm not worried about that at the moment.)

Could you run the push with the environment variable GIT_CURL_VERBOSE=1?

> [2]
> GET http://xxxxx:25989/git/foo/info/refs?service=git-receive-pack HTTP/1.1
> User-Agent: git/1.7.4.rc0
> Host: xxxxx:25989
> Accept: */*
> Proxy-Connection: Keep-Alive
> Pragma: no-cache

Try having a entry for xxxxx:25989 in your .netrc - that should be
sufficient to demonstrate to you that git+curl reads your .netrc.

-- 
Cheers,
Ray Chuan

```

## Junio C Hamano, 2011-01-13 00:42

Subject: Re: HTTP push not respecting .netrc
Message-ID: <7vy66p1vn3.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vy66p1vn3.fsf%40alter.siamese.dyndns.org
In-Reply-To: <AANLkTi=4cE711TtqE0E-05s9Pk72C8OymNf_-5NhrfXS@mail.gmail.com>

```
Has this been resolved to satisfaction?  Just being curious...

```

## David Borowitz, 2011-01-13 00:48

Subject: Re: HTTP push not respecting .netrc
Message-ID: <AANLkTik4v3Gf48RtqQtqNt5ocdCuqSZqPpBzx4RifyEp@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTik4v3Gf48RtqQtqNt5ocdCuqSZqPpBzx4RifyEp%40mail.gmail.com
In-Reply-To: <7vy66p1vn3.fsf@alter.siamese.dyndns.org>

```
On Wed, Jan 12, 2011 at 16:42, Junio C Hamano <gitster@pobox.com> wrote:
> Has this been resolved to satisfaction?  Just being curious...

I went on vacation, came back, and it magically worked (or maybe I
typed something else); you know how these things can be. I'll
definitely use those tips and respond on this thread if it happens
again.

```

## David Borowitz, 2011-01-27 02:47

Subject: Re: HTTP push not respecting .netrc
Message-ID: <AANLkTi=k5m+90wZPLMjah3cnL=4PjF5Skp2zkaTXyD09@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTi%3Dk5m%2B90wZPLMjah3cnL%3D4PjF5Skp2zkaTXyD09%40mail.gmail.com
In-Reply-To: <AANLkTi=cqsvXb3eywTfxAg9hH9cigumSQjoHqq5bnJfM@mail.gmail.com>

```
On Wed, Jan 26, 2011 at 18:00, David Borowitz <dave@bwitz.com> wrote:
> But this raises further questions:
> -Why does git/curl decide it's ok to retry with authentication in one
> case, but not in the other?

Poking further, it looks like curl is deciding not to retry because
the ioctl callback is failing to rewind the post buffer when clearly
it should be able to. So it's more likely a git bug than a curl issue
(the following question notwithstanding).

> -Why does curl send the auth header before ever receiving a 401, while
> git does not? (Would fixing this be as easy as setting another curl
> option?)

```
