Skip to content

Commit 4090092

Browse files
Merge pull request #13 from HatsuneMiku3939/feature/add-user-agent-option
add user agent option
2 parents 4174720 + 1869859 commit 4090092

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ The tag of the event.
120120

121121
The url of remote server.
122122

123+
### agent (string) (optional, default: fluent-plugin-http-pull)
124+
125+
The user agent string of request.
126+
123127
### interval (time) (required)
124128

125129
The interval time between periodic request.

fluent-plugin-http-pull.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
33

44
Gem::Specification.new do |spec|
55
spec.name = "fluent-plugin-http-pull"
6-
spec.version = "0.6.1"
6+
spec.version = "0.7.0"
77
spec.authors = ["filepang"]
88
spec.email = ["[email protected]"]
99

lib/fluent/plugin/in_http_pull.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ def initialize
3535
desc 'The interval time between periodic request'
3636
config_param :interval, :time
3737

38+
desc 'The user agent string of request'
39+
config_param :agent, :string, default: "fluent-plugin-http-pull"
40+
3841
desc 'status_only'
3942
config_param :status_only, :bool, default: false
4043

@@ -72,7 +75,8 @@ def configure(conf)
7275

7376
@parser = parser_create unless @status_only
7477
@_request_headers = {
75-
"Content-Type" => "application/x-www-form-urlencoded"
78+
"Content-Type" => "application/x-www-form-urlencoded",
79+
"User-Agent" => @agent
7680
}.merge(@request_headers.map do |section|
7781
header = section["header"]
7882
value = section["value"]

test/plugin/test_in_http_pull.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ class HttpPullInputTestDefaultOptions < Test::Unit::TestCase
5454

5555
assert_equal(:get, d.instance.http_method)
5656
end
57+
58+
test 'agent' do
59+
d = create_driver TEST_DEFAULT_VALUE_CONFIG
60+
assert_equal("test", d.instance.tag)
61+
62+
assert_equal("fluent-plugin-http-pull", d.instance.agent)
63+
end
5764
end
5865

5966
private

0 commit comments

Comments
 (0)