Skip to content
This repository was archived by the owner on Aug 31, 2018. It is now read-only.

Add parameter of ProxyConnectHeader #145

Merged
merged 6 commits into from
Dec 4, 2017

Conversation

kilisima
Copy link
Contributor

@kilisima kilisima commented Dec 2, 2017

Correspondence to parameters added in Golang 1.9
I want to assign parameters to the header for authentication to the Proxy

golang/go#19504

goreq.go Outdated

func (r *Request) AddProxyHeader(name string, value string) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe change this to AddProxyConnect header? Because these headers will be only sent during the connect phase according to the golang doc. Same for WithProxyHeader

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok.
Change the method name.

goreq_test.go Outdated
@@ -1065,6 +1066,98 @@ func TestRequest(t *testing.T) {

})

g.Describe("TLS Proxy", func() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test seem a bit overcomplicated. You just need to verify that the header gets passed to the proxy. No need to implement a whole proxy in the test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since I could not think of a simple test, I am wondering if there is no problem as a test.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kilisima what I'm saying is that you don't need to implement a whole proxy. You can safely remove the TLS server, and then do the assertion in the httptest server. No need to dial to a new server. You just need to assert that the headers arrive in the proxyCh which you're already doing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the TLS server from the test case and simplified the test case.
Thank you. I appreciate it.

Copy link
Member

@marcosnils marcosnils Dec 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kilisima thank you for doing that. After reviewing the PR again I realize that there's no need for a Describe("TLS Proxy") block as we're not testing anything related to TLS here. I think it's best if we remove that describe and we move the test to the Proxy describe block and re-use the http test server that's being used there which makes sense. That way everything will be consistent and even simpler.

Sorry to bring this up this late, It's that I just realized about that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Please check.

goreq_test.go Outdated
proxyCh <- r
// Implement an entire CONNECT proxy
if r.Method == "CONNECT" {
// hijacker, ok := w.(http.Hijacker)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to leave it commented you can go ahead and remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh...Sorry

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I deleted it.

@kilisima
Copy link
Contributor Author

kilisima commented Dec 4, 2017

@marcosnils Thanks to you I was helped. Please merge.

@marcosnils marcosnils merged commit bcd34c9 into franela:master Dec 4, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants