Skip to content

Commit

Permalink
fix(ndjson): Add ability to support content type override for ndjsone…
Browse files Browse the repository at this point in the history
…ncformatter

ElasticSearch 6.x no longer supports Content-Type: "application/x-ndjson; charset=UTF-8" in the
Request Header. Older versions of Firefox append the charset=UTF-8. Elastic does support
"application/json; charset=UTF-8".

THIN-13537
  • Loading branch information
rothmike committed May 20, 2019
1 parent 7f7ef46 commit 32ebb15
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/os/net/ndjsonencformatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,23 @@ goog.require('os.net.IDataFormatter');
/**
* Creates an application/json payload
* @implements {os.net.IDataFormatter}
* @param {Array<Object>} opt_content The JSON objects to format.
* @param {Array<Object>} content The JSON objects to format.
* @param {?function(string, *)=} opt_replacer The JSON object to format.
* @param {string=} opt_contentType The Content-Type to set.
* @constructor
*/
os.net.NDJsonEncFormatter = function(opt_content, opt_replacer) {
os.net.NDJsonEncFormatter = function(content, opt_replacer, opt_contentType) {
/**
* @type {Array<Object>}
* @private
*/
this.content_ = opt_content;
this.content_ = content;

/**
* @type {string|undefined}
* @private
*/
this.opt_contentType_ = opt_contentType;
};


Expand All @@ -39,7 +46,7 @@ os.net.NDJsonEncFormatter.prototype.setContent = function(content) {
* @inheritDoc
*/
os.net.NDJsonEncFormatter.prototype.getContentType = function() {
return 'application/x-ndjson';
return this.opt_contentType_ || 'application/x-ndjson';
};


Expand Down

0 comments on commit 32ebb15

Please sign in to comment.