Cscott has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/300441

Change subject: Don't JSON-decode the response of html/to/wikitext/ request in 
roundtrip-test.
......................................................................

Don't JSON-decode the response of html/to/wikitext/ request in roundtrip-test.

The result of this API call is wikitext, not a JSON blob.  It currently
works only because the http library silently swallows the decode exception.

Change-Id: I5ef16832c5479b519d4c74943c2ca5af385371e1
---
M bin/roundtrip-test.js
1 file changed, 7 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid 
refs/changes/41/300441/1

diff --git a/bin/roundtrip-test.js b/bin/roundtrip-test.js
index dd2a627..2dd60b9 100755
--- a/bin/roundtrip-test.js
+++ b/bin/roundtrip-test.js
@@ -473,7 +473,6 @@
 function parsoidPost(profile, options) {
        var httpOptions = {
                method: 'POST',
-               json: true,
                body: options.data,
        };
 
@@ -484,11 +483,18 @@
                        uri += '/' + options.oldid;
                }
                httpOptions.body.scrub_wikitext = true;
+               // We want to encode the request but *not* decode the response.
+               httpOptions.body = JSON.stringify(httpOptions.body);
+               httpOptions.headers = {
+                       'Content-Type': 'application/json',
+               };
        } else {  // wt2html
                uri += 'wikitext/to/pagebundle/' + options.title;
                httpOptions.headers = {
                        Accept: apiUtils.pagebundleContentType(null, 
options.contentVersion),
                };
+               // setting json here encodes the request *and* decodes the 
response.
+               httpOptions.json = true;
        }
        httpOptions.uri = uri;
 

-- 
To view, visit https://gerrit.wikimedia.org/r/300441
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5ef16832c5479b519d4c74943c2ca5af385371e1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Cscott <canan...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to