Method: DatadogAPIClient::APIClient#build_request_body
- Defined in:
- lib/datadog_api_client/api_client.rb
#build_request_body(header_params, form_params, body) ⇒ String
Build the HTTP request body
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'lib/datadog_api_client/api_client.rb', line 231 def build_request_body(header_params, form_params, body) # http form if header_params['Content-Type'] == 'application/x-www-form-urlencoded' || header_params['Content-Type'] == 'multipart/form-data' data = {} form_params.each do |key, value| case value when ::File, ::Array, nil # let httparty handle File, Array and nil parameters data[key] = value else data[key] = value.to_s end end elsif body data = body.is_a?(String) ? body : body.to_json else data = nil end if header_params['Content-Encoding'] == 'gzip' gzip = Zlib::Deflate.new(nil, Zlib::MAX_WBITS + 16) data = gzip.deflate(data, Zlib::FINISH) gzip.close elsif header_params['Content-Encoding'] == 'deflate' data = Zlib::deflate(data) elsif header_params['Content-Encoding'] == 'zstd1' data = Zstandard.deflate(data) end data end |