Skip to content

Commit 1fc614d

Browse files
author
Montana Flynn
committed
2 parents ae0c1bf + f561925 commit 1fc614d

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ currently the following output [targets](/src/targets) are supported:
2929
- [HTTPie](http://httpie.org)
3030
- Node.js
3131
- [Native](http://nodejs.org/api/http.html#http_http_request_options_callback)
32+
- [Request](https://github.com/request/request)
33+
- OCaml
34+
- [CoHTTP](https://github.com/mirage/ocaml-cohttp)
3235
- PHP
3336
- [ext-curl](http://php.net/manual/en/book.curl.php)
3437
- [Wget](https://www.gnu.org/software/wget/)

src/index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,15 @@ var HTTPSnippet = function (req, lang) {
4949

5050
case 'application/json':
5151
if (this.source.postData.text) {
52-
this.source.postData.jsonObj = JSON.parse(this.source.postData.text);
52+
try {
53+
this.source.postData.jsonObj = JSON.parse(this.source.postData.text);
54+
} catch (e) {
55+
debug(e);
56+
57+
// force back to text/plain
58+
// if headers have proper content-type value, then this should also work
59+
this.source.postData.mimeType = 'text/plain'
60+
}
5361
}
5462
break;
5563
}

src/targets/ocaml/cohttp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ module.exports = function (options) {
7575

7676
module.exports.info = {
7777
key: 'cohttp',
78-
title: 'OCaml',
78+
title: 'CoHTTP',
7979
link: 'https://github.com/mirage/ocaml-cohttp',
8080
description: 'Cohttp is a very lightweight HTTP server using Lwt or Async for OCaml'
8181
};

0 commit comments

Comments
 (0)