Skip to content

Only set Content-Type if empty

Brian Williams requested to merge bwill/fix-changelog into master

Why is this change being made?

In !2595 (merged) I refactored some of the Rakefile requests and inadvertently broke the changelog generation.

Previously, the changelog rake task had this code:

    req = Net::HTTP::Post.new(uri)
    req['PRIVATE-TOKEN'] = ENV['CS_TOKEN']
    req['Content-Type'] = 'application/json'
    req.set_form_data(version: ENV['CI_COMMIT_TAG'])
    res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
      http.request(req)
    end

req.set_form_data changes the Content-Type to application/x-www-form-urlencoded, so the req['Content-Type'] = 'application/json' on the line before was misleading. Having the Content-Type set to application/json causes the changelog endpoint to return 400.

This MR fixes this by only setting the Content-Type header if it is empty.

Edited by Brian Williams

Merge request reports