# File lib/webmock/http_lib_adapters/patron_adapter.rb, line 73
        def self.build_request_signature(req)
          uri = WebMock::Util::URI.heuristic_parse(req.url)
          uri.path = uri.normalized_path.gsub("[^:]//","/")
          uri.user = req.username
          uri.password = req.password

          if [:put, :post].include?(req.action)
            if req.file_name
              if !File.exist?(req.file_name) || !File.readable?(req.file_name)
                raise ArgumentError.new("Unable to open specified file.")
              end
              request_body = File.read(req.file_name)
            elsif req.upload_data
              request_body = req.upload_data
            else
              raise ArgumentError.new("Must provide either data or a filename when doing a PUT or POST")
            end
          end

          request_signature = WebMock::RequestSignature.new(
            req.action,
            uri.to_s,
            :body => request_body,
            :headers => req.headers
          )
          request_signature
        end