Skip to content

Commit

Permalink
fix(webhooks): use path to initialise http request, rather than full URL
Browse files Browse the repository at this point in the history
This is required to make the request work for the slack notifications API, which returns a 302 if the full URL is used. ¯\_(ツ)_/¯

eg.

SSL established
<- "POST https://hooks.slack.com/services/TOKEN

vs

SSL established
<- "POST /services/TOKEN
  • Loading branch information
bethesque committed Sep 23, 2020
1 parent 0c1e23f commit ecbac9a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/pact_broker/domain/webhook_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def execute

def http_request
@http_request ||= begin
req = Net::HTTP.const_get(method.capitalize).new(url)
req = Net::HTTP.const_get(method.capitalize).new(uri.request_uri)
headers.each_pair { | name, value | req[name] = value }
req.basic_auth(username, password) if username && username.size > 0
req.body = body unless body.nil?
Expand Down

2 comments on commit ecbac9a

@mefellows
Copy link
Member

Choose a reason for hiding this comment

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

Turns out this is an issue in other scenarios also, so good to have fixed it!

Screen Shot 2020-09-24 at 9 58 28 am

@bethesque
Copy link
Member Author

Choose a reason for hiding this comment

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

So strange that this code hasn't changed for years, and all of a sudden there is an issue noticed twice in two days. I wonder if a new version of some widely used server software has come out recently.

Please sign in to comment.