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

[check-http] add --proxy option #277

Merged
merged 8 commits into from
Feb 21, 2019
Merged

[check-http] add --proxy option #277

merged 8 commits into from
Feb 21, 2019

Conversation

astj
Copy link
Contributor

@astj astj commented Feb 20, 2019

Although check-http can request using proxy via HTTP_PROXY environment variable, imo it's useful when we can specify the proxy url from command line option.

@@ -30,6 +31,7 @@ type checkHTTPOpts struct {
Regexp string `short:"p" long:"pattern" description:"Expected pattern in the content"`
MaxRedirects int `long:"max-redirects" description:"Maximum number of redirects followed" default:"10"`
ConnectTos []string `long:"connect-to" value-name:"HOST1:PORT1:HOST2:PORT2" description:"Request to HOST2:PORT2 instead of HOST1:PORT1"`
Proxy string `short:"x" long:"proxy" value-name:"[PROTOCOL://]HOST[:PORT]" description:"Use the specified proxy. PROTOCOL's default is http, and PORT's default is 1080."`
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] Should add note that can pass http://user:password@proxy.com ? (but it's long-winded)

Copy link
Contributor Author

@astj astj Feb 21, 2019

Choose a reason for hiding this comment

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

Hmm, command line description is so narrow to describe everything, but adding [USER:PASS@] seems acceptable.
Thank you for suggestion. I added at description (and tests for safe) at c92b856

@@ -50,6 +50,7 @@ command = ["check-http", "-u", "http://example.com"]
-p, --pattern= Expected pattern in the content
--max-redirects= Maximum number of redirects followed (default: 10)
--connect-to=HOST1:PORT1:HOST2:PORT2 Request to HOST2:PORT2 instead of HOST1:PORT1
-x, --proxy=[PROTOCOL://]HOST[:PORT] Use the specified proxy. PROTOCOL's default is http, and PORT's default is 1080.
Copy link
Contributor

@syou6162 syou6162 Feb 21, 2019

Choose a reason for hiding this comment

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

Is there any reasons why you select 1080 as default port?

OK, I understood port 1080 is often used as SOCKS proxy port.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Those default values are taken from curl.

       -x, --proxy [protocol://]host[:port]
              Use the specified proxy.

              The  proxy  string  can  be  specified with a protocol:// prefix. No protocol specified or http:// will be treated as HTTP proxy. Use socks4://, socks4a://, socks5:// or
              socks5h:// to request a specific SOCKS version to be used.  (The protocol support was added in curl 7.21.7)

              HTTPS proxy support via https:// protocol prefix was added in 7.52.0 for OpenSSL, GnuTLS and NSS.

              Unrecognized and unsupported proxy protocols cause an error since 7.52.0.  Prior versions may ignore the protocol and use http:// instead.

              If the port number is not specified in the proxy string, it is assumed to be 1080.

              This option overrides existing environment variables that set the proxy to use. If there's an environment variable setting a proxy, you can set proxy to ""  to  override
              it.

              All  operations that are performed over an HTTP proxy will transparently be converted to HTTP. It means that certain protocol specific operations might not be available.
              This is not the case if you can tunnel through the proxy, as one with the -p, --proxytunnel option.

              User and password that might be provided in the proxy string are URL decoded by curl. This allows you to pass in special characters such as @ by using %40 or pass  in  a
              colon with %3a.

              The proxy host can be specified the exact same way as the proxy environment variables, including the protocol prefix (http://) and the embedded user + password.

              If this option is used several times, the last one will be used.

@astj astj changed the title add --proxy option to check-http [check-http] add --proxy option Feb 21, 2019
@astj
Copy link
Contributor Author

astj commented Feb 21, 2019

Thank you for review!

@astj astj merged commit 25c1372 into master Feb 21, 2019
@astj astj deleted the check-http-add-proxy branch February 21, 2019 07:25
@lufia lufia mentioned this pull request Mar 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants