KETTLE-51: kettle.dataSource.URL.writable does not calculate data length correctly when data contains special character(s)

Metadata

Source
KETTLE-51
Type
Bug
Priority
Major
Status
Resolved
Resolution
Fixed
Assignee
Cindy Li
Reporter
Cindy Li
Created
2016-12-23T09:54:40.954-0500
Updated
2017-01-05T20:16:21.920-0500
Versions
  1. 1.0
Fixed Versions
N/A
Component
N/A

Description

This issue was discovered at sending PUT request to CouchDB `/_bulk_docs` API in order to load JSON data that contains special characters such as "ä". CouchDB returns error:

{"error":"bad_request","reason":"invalid_json"}

This is because, the function kettle.dataSource.URL.handle.http() in dataSource-url.js use `data.length` to calculate "Content-Length" of the http request. `data.length` calculates the number of chars instead of the number of bytes, which causes problem when a special character exists in the post data. To fix it, the data should be converted with `data = new Buffer(data);` to get the proper length in bytes.