Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
telegraf-nftables
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Due to inactivity, this project is scheduled to be deleted on 2035-04-24.
Why is this scheduled?
Show more breadcrumbs
vqgroup
telegraf-nftables
Commits
ad5e9540
Commit
ad5e9540
authored
7 years ago
by
Marcel
Committed by
Daniel Nelson
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add ability to override proxy from environment in http response (#3626)
parent
93b2870b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
plugins/inputs/http_response/http_response.go
+21
-1
21 additions, 1 deletion
plugins/inputs/http_response/http_response.go
with
21 additions
and
1 deletion
plugins/inputs/http_response/http_response.go
+
21
−
1
View file @
ad5e9540
...
...
@@ -20,6 +20,7 @@ import (
// HTTPResponse struct
type
HTTPResponse
struct
{
Address
string
Proxy
string
Body
string
Method
string
ResponseTimeout
internal
.
Duration
...
...
@@ -49,6 +50,9 @@ var sampleConfig = `
## Server address (default http://localhost)
# address = "http://localhost"
## Set http_proxy (telegraf uses the system wide proxy settings if it's is not set)
# http_proxy = "http://localhost:8888"
## Set response_timeout (default 5 seconds)
# response_timeout = "5s"
...
...
@@ -88,6 +92,22 @@ func (h *HTTPResponse) SampleConfig() string {
// ErrRedirectAttempted indicates that a redirect occurred
var
ErrRedirectAttempted
=
errors
.
New
(
"redirect"
)
// Set the proxy. A configured proxy overwrites the system wide proxy.
func
getProxyFunc
(
http_proxy
string
)
func
(
*
http
.
Request
)
(
*
url
.
URL
,
error
)
{
if
http_proxy
==
""
{
return
http
.
ProxyFromEnvironment
}
proxyURL
,
err
:=
url
.
Parse
(
http_proxy
)
if
err
!=
nil
{
return
func
(
_
*
http
.
Request
)
(
*
url
.
URL
,
error
)
{
return
nil
,
errors
.
New
(
"bad proxy: "
+
err
.
Error
())
}
}
return
func
(
r
*
http
.
Request
)
(
*
url
.
URL
,
error
)
{
return
proxyURL
,
nil
}
}
// CreateHttpClient creates an http client which will timeout at the specified
// timeout period and can follow redirects if specified
func
(
h
*
HTTPResponse
)
createHttpClient
()
(
*
http
.
Client
,
error
)
{
...
...
@@ -98,7 +118,7 @@ func (h *HTTPResponse) createHttpClient() (*http.Client, error) {
}
client
:=
&
http
.
Client
{
Transport
:
&
http
.
Transport
{
Proxy
:
http
.
ProxyF
romEnvironment
,
Proxy
:
get
ProxyF
unc
(
h
.
Proxy
)
,
DisableKeepAlives
:
true
,
TLSClientConfig
:
tlsCfg
,
},
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment