Skip to content

Commit

Permalink
MINOR: httpchk: add support for host param
Browse files Browse the repository at this point in the history
  • Loading branch information
rmaticevic authored and mjuraga committed Dec 23, 2024
1 parent 4c78f49 commit cd0563e
Show file tree
Hide file tree
Showing 15 changed files with 46 additions and 6 deletions.
11 changes: 9 additions & 2 deletions config-parser/parsers/option-httpchk.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,16 @@ func (s *OptionHttpchk) Parse(line string, parts []string, comment string) (stri
Version: parts[4],
Comment: comment,
}
default: // > 5
case 6:
s.data = &types.OptionHttpchk{
Method: parts[2],
URI: parts[3],
Version: strings.Join(parts[4:], " "),
Version: parts[4],
Host: parts[5],
Comment: comment,
}
default: // > 6
return "", &errors.ParseError{Parser: "option httpchk", Line: line}
}
return "", nil
}
Expand All @@ -90,6 +93,10 @@ func (s *OptionHttpchk) Result() ([]common.ReturnResultLine, error) {
sb.WriteString(" ")
sb.WriteString(s.data.Version)
}
if s.data.Host != "" {
sb.WriteString(" ")
sb.WriteString(s.data.Host)
}
return []common.ReturnResultLine{
{
Data: sb.String(),
Expand Down
4 changes: 4 additions & 0 deletions config-parser/tests/integration/backend_data_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions config-parser/tests/integration/backend_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions config-parser/tests/integration/defaults_data_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions config-parser/tests/integration/defaults_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions config-parser/tests/option-httpchk_generated_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions config-parser/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -782,11 +782,13 @@ type OptionForwardFor struct {
//test:ok:option httpchk <uri>
//test:ok:option httpchk <method> <uri>
//test:ok:option httpchk <method> <uri> <version>
//test:ok:option httpchk <method> <uri> <version> <host>
type OptionHttpchk struct {
NoOption bool
Method string
URI string
Version string
Host string
Comment string
}

Expand Down
2 changes: 2 additions & 0 deletions configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,7 @@ func (s *SectionParser) getHttpchkData() (bool, interface{}) {
Method: d.Method,
URI: d.URI,
Version: d.Version,
Host: d.Host,
})
return true, "httpchk"
}
Expand Down Expand Up @@ -2093,6 +2094,7 @@ func (s *SectionObject) getHTTPChkData() (common.ParserData, error) {
Method: params.Method,
Version: params.Version,
URI: params.URI,
Host: params.Host,
}, nil
}

Expand Down
4 changes: 4 additions & 0 deletions models/httpchk_params.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions models/httpchk_params_compare.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions models/httpchk_params_compare_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions specification/build/haproxy_spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9963,6 +9963,8 @@ definitions:
title: Default Server
httpchk_params:
properties:
host:
type: string
method:
enum:
- HEAD
Expand Down
2 changes: 2 additions & 0 deletions specification/models/configuration/misc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ httpchk_params:
pattern: '^[^ ]*$'
version:
type: string
host:
type: string
redispatch:
type: object
required:
Expand Down
2 changes: 1 addition & 1 deletion test/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ backend test
log-tag bla
option http-keep-alive
option forwardfor header X-Forwarded-For
option httpchk HEAD /
option httpchk HEAD / HTTP/1.1 www
option tcpka
option srvtcpka
option checkcache
Expand Down
4 changes: 3 additions & 1 deletion test/expected/structured.json
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,9 @@
"http_send_name_header": "X-My-Awesome-Header",
"httpchk_params": {
"method": "HEAD",
"uri": "/"
"uri": "/",
"version": "HTTP/1.1",
"host": "www"
},
"id": 456,
"ignore_persist_list": [
Expand Down

0 comments on commit cd0563e

Please sign in to comment.