Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http.Get uses proxy incorrectly: 502 bad gateway #53

Closed
gopherbot opened this issue Nov 11, 2009 · 21 comments
Closed

http.Get uses proxy incorrectly: 502 bad gateway #53

gopherbot opened this issue Nov 11, 2009 · 21 comments

Comments

@gopherbot
Copy link

by GSXygon:

What steps will reproduce the problem?
1. operate behind proxy
2. set http_proxy to appropriate envvar
3. run ./all.bash

What is the expected output? What do you see instead?
Should pass make
On 
  gopack grc _test/http.a _gotest_.6

-- FAIL: http.TestClient
  .... no answer from server
-- FAIL: http.TestRedirect
  ... no answer from server

What is your $GOOS?  $GOARCH?
GOOS=darwin
GOARCH=amd_64
@gopherbot
Copy link
Author

Comment 1 by GSXygon:

Workaround in issue ID 5
add net and http to NOTEST in src/Makefile
Still an issue, should recognize http_proxy

@agl
Copy link
Contributor

agl commented Nov 11, 2009

Comment 2:

Labels changed: added package-bug.

Status changed to Accepted.

@gopherbot
Copy link
Author

Comment 4 by akunokuroneko:

I have a patch for this, but it's fugly.  See http://golang.org/cl/154042

@gopherbot
Copy link
Author

Comment 5 by christopher.hesse:

GSXygon means src/pkg/Makefile

@rsc
Copy link
Contributor

rsc commented Nov 15, 2009

Comment 6:

Owner changed to r...@golang.org.

@rsc
Copy link
Contributor

rsc commented Dec 2, 2009

Comment 7:

Labels changed: added packagebug, removed package-bug.

@gopherbot
Copy link
Author

Comment 8 by dean.prichard:

How about something like this as a temp. workaround?
--- a/src/pkg/Makefile  Tue Jan 12 10:03:02 2010 -0800
+++ b/src/pkg/Makefile  Wed Jan 13 11:34:27 2010 -0700
@@ -134,6 +134,14 @@
    testing/iotest\
    xgb\
 
+NOTESTFW=\
+   net\
+   http\
+
+ifdef http_proxy
+NOTEST+=$(NOTESTFW)
+endif
+
 TEST=\
    $(filter-out $(NOTEST),$(DIRS))

@agl
Copy link
Contributor

agl commented Feb 16, 2011

Comment 9:

This issue was closed by revision f04b5a3.

Status changed to Fixed.

@gopherbot
Copy link
Author

Comment 10 by nuno.mt.sousa:

I made a new build and the tests are failing for the http request due to the proxy code.
--- FAIL: http.TestClientHead (0.0 seconds)
        Last-Modified header not found.
--- FAIL: http.TestRedirect (0.0 seconds)
        Get(http://google.com/) got status 502 at "http://google.com/", want 200 matching "^http://www\\.google\\.[a-z.]+/$"
FAIL
Here is the important part (from wireshark):
GET /robots.txt HTTP/1.1
Host: www.google.com
User-Agent: Go http package
HTTP/1.1 502 Proxy Error ( The Uniform Resource Locator (URL) does not use a recognized
protocol. Either the protocol is not supported or the request was not typed correctly.
Confirm that a valid protocol is in use (for example, HTTP for a Web request).  )
Via: 1.1 PTLIPRX003
Connection: close
Proxy-Connection: close
Pragma: no-cache
Cache-Control: no-cache
Content-Type: text/html
Content-Length: 4224
It seems that something is missing. If I do this on the command line it works:
telnet 10.152.138.65 8080
Trying 10.152.138.65...
Connected to 10.152.138.65.
Escape character is '^]'.
GET http://www.google.com/robots.txt HTTP/1.1
HTTP/1.1 200 OK
Via: 1.1 PTLIPRX004, 1.1 PTLIPRX001, 1.1 PTLIPRX003
Connection: Keep-Alive
Proxy-Connection: Keep-Alive
Transfer-Encoding: chunked
Expires: Thu, 17 Feb 2011 11:18:09 GMT
Date: Thu, 17 Feb 2011 11:18:09 GMT
Content-Type: text/plain
Server: sffe
Last-Modified: Mon, 14 Feb 2011 19:41:32 GMT
Cache-Control: private, max-age=0
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
1000
User-agent: *
Disallow: /search
...

@rsc
Copy link
Contributor

rsc commented Feb 17, 2011

Comment 11:

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Mar 3, 2011

Comment 12:

did 
changeset:   7498:afc3d9f30d78
user:        Russ Cox <rsc@golang.org>
date:        Thu Feb 17 17:14:50 2011 -0500
summary:     http: send full URL in proxy requests
fix this?

@gopherbot
Copy link
Author

Comment 13 by nuno.mt.sousa:

Where can I get that changeset?
I updated to the latest source and the behavior is the same as I reported in Comment 10.
If this changeset is somewhere I can fetch and apply to test it I'll do it.

@rsc
Copy link
Contributor

rsc commented Mar 4, 2011

Comment 14:

What does 6g -V (or 8g -V) print on your updated system?

@gopherbot
Copy link
Author

Comment 15 by nuno.mt.sousa:

8g -V prints:
8g version release.2011-02-24 7628

@rsc
Copy link
Contributor

rsc commented Mar 4, 2011

Comment 16:

That version should have the relevant change.
Can you run wireshark and see what the request says?
It is supposed to say what you typed in the telnet session.
Thanks.
Russ

@gopherbot
Copy link
Author

Comment 17 by nuno.mt.sousa:

Hi.
Ran with wireshark again and what is sent on the wire is basically the same. Here is the
contents of the TCP Connection (I omitted the rest of the HTML page returned by the
proxy):
GET / HTTP/1.1
Host: google.com
User-Agent: Go http package
HTTP/1.1 502 Proxy Error ( The Uniform Resource Locator (URL) does not use a recognized
protocol. Either the protocol is not supported or the request was not typed correctly.
Confirm that a valid protocol is in use (for example, HTTP for a Web request).  )
Via: 1.1 PTLIPRX001
Connection: close
Proxy-Connection: close
Pragma: no-cache
Cache-Control: no-cache
Content-Type: text/html
Content-Length: 4222  
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Error Message</TITLE>
I made a full rebuild just to be sure and checked that I had no changed files locally
(hg status).
Any thing I can do to help debug it?
Thanks.
Nuno

@rsc
Copy link
Contributor

rsc commented Mar 4, 2011

Comment 18:

The code I wrote last time is just wrong, and untested.
I added a test and tried to do a better job.
Will update the issue when the code is submitted.

@rsc
Copy link
Contributor

rsc commented Mar 5, 2011

Comment 19:

This issue was closed by revision 7bc90ed.

Status changed to Fixed.

@gopherbot
Copy link
Author

Comment 20 by nuno.mt.sousa:

I tested behind a firewall with a proxy (sorry for the delay, Carnival :-) ).
The http pkg now seems to work well. All the tests pass even when ran behind a firewall.
But now the net pkg tests fail behind a firewall. Probably because some test was added
there. I supposed these tests will never work behind a firewall...
Here is the output of the build after it fails:
gopack grc _test/net.a _gotest_.8 
make[2]: Leaving directory `/home/nsousa/Projects/google-go/src/pkg/net'
--- FAIL: net.TestDialGoogle (5683.3 seconds)
        -- 72.14.204.104:80 --
        Dial("tcp", "", "72.14.204.104:80") = _, dial tcp 72.14.204.104:80: connection timed out
        Dial("tcp4", "", "72.14.204.104:80") = _, dial tcp4 72.14.204.104:80: connection timed out
        Dial("tcp4", "", "72.14.204.104:80") = _, dial tcp4 72.14.204.104:80: connection timed out
        Dial("tcp6", "", "72.14.204.104:80") = _, dial tcp6 72.14.204.104:80: connection timed out
        -- www.google.com:80 --
        Dial("tcp", "", "www.google.com:80") = _, dial tcp 72.14.204.99:80: connection timed out
        Dial("tcp4", "", "www.google.com:80") = _, dial tcp4 72.14.204.103:80: connection timed out
        Dial("tcp4", "", "www.google.com:80") = _, dial tcp4 72.14.204.147:80: connection timed out
        Dial("tcp6", "", "www.google.com:80") = _, dial tcp6 72.14.204.99:80: connection timed out
        -- 72.14.204.104:http --
        Dial("tcp", "", "72.14.204.104:http") = _, dial tcp 72.14.204.104:80: connection timed out
        Dial("tcp4", "", "72.14.204.104:http") = _, dial tcp4 72.14.204.104:80: connection timed out
        Dial("tcp4", "", "72.14.204.104:http") = _, dial tcp4 72.14.204.104:80: connection timed out
        Dial("tcp6", "", "72.14.204.104:http") = _, dial tcp6 72.14.204.104:80: connection timed out
        -- www.google.com:http --
        Dial("tcp", "", "www.google.com:http") = _, dial tcp 72.14.204.104:80: connection timed out
        Dial("tcp4", "", "www.google.com:http") = _, dial tcp4 74.125.225.19:80: connection timed out
        Dial("tcp4", "", "www.google.com:http") = _, dial tcp4 72.14.204.99:80: connection timed out
        Dial("tcp6", "", "www.google.com:http") = _, dial tcp6 74.125.225.16:80: connection timed out
        -- 072.014.204.104:0080 --
        Dial("tcp", "", "072.014.204.104:0080") = _, dial tcp 72.14.204.104:80: connection timed out
        Dial("tcp4", "", "072.014.204.104:0080") = _, dial tcp4 72.14.204.104:80: connection timed out
        Dial("tcp4", "", "072.014.204.104:0080") = _, dial tcp4 72.14.204.104:80: connection timed out
        Dial("tcp6", "", "072.014.204.104:0080") = _, dial tcp6 72.14.204.104:80: connection timed out
        -- [::ffff:72.14.204.104]:80 --
        Dial("tcp", "", "[::ffff:72.14.204.104]:80") = _, dial tcp 72.14.204.104:80: connection timed out
        Dial("tcp6", "", "[::ffff:72.14.204.104]:80") = _, dial tcp6 72.14.204.104:80: connection timed out
        -- [::ffff:480e:cc68]:80 --
        Dial("tcp", "", "[::ffff:480e:cc68]:80") = _, dial tcp 72.14.204.104:80: connection timed out
        Dial("tcp6", "", "[::ffff:480e:cc68]:80") = _, dial tcp6 72.14.204.104:80: connection timed out
        -- [0:0:0:0:0000:ffff:72.14.204.104]:80 --
        Dial("tcp", "", "[0:0:0:0:0000:ffff:72.14.204.104]:80") = _, dial tcp 72.14.204.104:80: connection timed out
        Dial("tcp6", "", "[0:0:0:0:0000:ffff:72.14.204.104]:80") = _, dial tcp6 72.14.204.104:80: connection timed out
        -- [0:0:0:0:000000:ffff:72.14.204.104]:80 --
        Dial("tcp", "", "[0:0:0:0:000000:ffff:72.14.204.104]:80") = _, dial tcp 72.14.204.104:80: connection timed out
        Dial("tcp6", "", "[0:0:0:0:000000:ffff:72.14.204.104]:80") = _, dial tcp6 72.14.204.104:80: connection timed out
        -- [0:0:0:0:0:ffff::72.14.204.104]:80 --
        Dial("tcp", "", "[0:0:0:0:0:ffff::72.14.204.104]:80") = _, dial tcp 72.14.204.104:80: connection timed out
        Dial("tcp6", "", "[0:0:0:0:0:ffff::72.14.204.104]:80") = _, dial tcp6 72.14.204.104:80: connection timed out
FAIL
make[1]: *** [test] Error 1
make[1]: Leaving directory `/home/nsousa/Projects/google-go/src/pkg/net'
make: *** [net.test] Error 2

@rsc
Copy link
Contributor

rsc commented Mar 11, 2011

Comment 21:

Yes, the package net tests depend on an external network.
export DISABLE_NET_TESTS=1
to make all.bash complete in your restricted environment.
Russ

@gopherbot
Copy link
Author

Comment 22 by nuno.mt.sousa:

Yep. It all works now.
Thanks.

minux pushed a commit to minux/goios that referenced this issue Feb 27, 2015
This is compiled as:
	MOV poollit(PC), REGTEMP
	ADD SP, REGTMP, R

This change allows DWORDs for C_LACON in optab, and sets the pool literal
correctly in addpool.

Fixes golang#53
@golang golang locked and limited conversation to collaborators Jun 24, 2016
@rsc rsc removed their assignment Jun 22, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants