Skip to content

Commit 36ed4c4

Browse files
committed
Merge branch 'master' of github.com:ahmadnassri/httpsnippet
2 parents d04b007 + f561925 commit 36ed4c4

3 files changed

Lines changed: 13 additions & 2 deletions

File tree

‎README.md‎

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

‎src/index.js‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,15 @@ var HTTPSnippet = function (req, lang) {
108108
case 'application/json':
109109
case 'application/x-json':
110110
if (this.source.postData.text) {
111-
this.source.postData.jsonObj = JSON.parse(this.source.postData.text);
111+
try {
112+
this.source.postData.jsonObj = JSON.parse(this.source.postData.text);
113+
} catch (e) {
114+
debug(e);
115+
116+
// force back to text/plain
117+
// if headers have proper content-type value, then this should also work
118+
this.source.postData.mimeType = 'text/plain'
119+
}
112120
}
113121
break;
114122
}

‎src/targets/ocaml/cohttp.js‎

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

6565
module.exports.info = {
6666
key: 'cohttp',
67-
title: 'OCaml',
67+
title: 'CoHTTP',
6868
link: 'https://github.com/mirage/ocaml-cohttp',
6969
description: 'Cohttp is a very lightweight HTTP server using Lwt or Async for OCaml'
7070
};

0 commit comments

Comments
 (0)