Bug setting http headers in Files API

Summary

In https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/19439 almost all the data info was added as headers to every request.

But it seems to be a bug, or at least with the Thin server. It raises an error every time we make a request to the files endpoints.

Steps to reproduce

What is the current bug behavior?

it raises an error

What is the expected correct behavior?

It shouldn't raise any error and return the file information.

Relevant logs and/or screenshots

This is the content to be set in the request headers:

{
    "file_name": "Gemfile",
    "file_path": "Gemfile",
    "size": 2221,
    "encoding": "base64",
    "content_sha256": "71048f83f2c3a0127c33731d91d5b928757df08d59481bd18fb23312a03ef735",
    "ref": "master",
    "blob_id": "79998b981228f90e90bf858273d0542cc4f3c6c0",
    "commit_id": "816a358c2327a06f954d14d6e519b4eada052485",
    "last_commit_id": "816a358c2327a06f954d14d6e519b4eada052485"    
}

The part of Thin that raises the error is lib/thin/response.rb#headers=

    def headers=(key_value_pairs)
      key_value_pairs.each do |k, vs|
         next unless vs
         if vs.is_a?(String)
           vs.each_line { |v| @headers[k] = v.chomp }
         else
           vs.each { |v| @headers[k] = v.chomp }
         end
      end if key_value_pairs
    end

Possible fixes

The headers= method does not accept Integer values. So basically the fix would be adding value.to_s to API::Helpers::HeadersHelpers

Edited by Francisco Javier López