@readme/httpsnippet 3.1.3 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (319) hide show
  1. package/README.md +63 -62
  2. package/dist/package.json +86 -0
  3. package/dist/src/fixtures/customTarget.js +15 -0
  4. package/dist/src/fixtures/mimetypes.js +77 -0
  5. package/dist/src/fixtures/requests/application-form-encoded.js +69 -0
  6. package/dist/src/fixtures/requests/application-json.js +72 -0
  7. package/dist/src/fixtures/requests/cookies.js +51 -0
  8. package/dist/src/fixtures/requests/custom-method.js +41 -0
  9. package/dist/src/fixtures/requests/full.js +99 -0
  10. package/dist/src/fixtures/requests/headers.js +56 -0
  11. package/dist/src/fixtures/requests/http-insecure.js +45 -0
  12. package/dist/src/fixtures/requests/jsonObj-multiline.js +59 -0
  13. package/dist/src/fixtures/requests/jsonObj-null-value.js +61 -0
  14. package/dist/src/fixtures/requests/multipart-data.js +72 -0
  15. package/dist/src/fixtures/requests/multipart-file.js +65 -0
  16. package/dist/src/fixtures/requests/multipart-form-data-no-params.js +56 -0
  17. package/dist/src/fixtures/requests/multipart-form-data.js +64 -0
  18. package/dist/src/fixtures/requests/nested.js +64 -0
  19. package/dist/src/fixtures/requests/query-encoded.js +59 -0
  20. package/dist/src/fixtures/requests/query.js +64 -0
  21. package/dist/src/fixtures/requests/short.js +45 -0
  22. package/dist/src/fixtures/requests/text-plain.js +57 -0
  23. package/dist/src/fixtures/runCustomFixtures.js +77 -0
  24. package/dist/src/helpers/code-builder.js +91 -0
  25. package/dist/src/helpers/form-data.js +157 -0
  26. package/dist/src/helpers/har-validator.js +76 -0
  27. package/dist/src/helpers/headers.js +33 -0
  28. package/dist/src/helpers/reducer.js +19 -0
  29. package/dist/src/helpers/shell.js +20 -0
  30. package/dist/src/helpers/utils.js +21 -0
  31. package/dist/src/index.js +285 -0
  32. package/dist/src/targets/c/libcurl/client.js +43 -0
  33. package/dist/src/targets/c/target.js +15 -0
  34. package/dist/src/targets/clojure/clj_http/client.js +184 -0
  35. package/dist/src/targets/clojure/target.js +15 -0
  36. package/dist/src/targets/csharp/httpclient/client.js +162 -0
  37. package/dist/src/targets/csharp/restsharp/client.js +38 -0
  38. package/dist/src/targets/csharp/target.js +17 -0
  39. package/dist/src/targets/go/native/client.js +122 -0
  40. package/dist/src/targets/go/target.js +15 -0
  41. package/dist/src/targets/http/http1.1/client.js +79 -0
  42. package/dist/src/targets/http/target.js +15 -0
  43. package/dist/src/targets/java/asynchttp/client.js +53 -0
  44. package/dist/src/targets/java/nethttp/client.js +52 -0
  45. package/dist/src/targets/java/okhttp/client.js +79 -0
  46. package/dist/src/targets/java/target.js +21 -0
  47. package/dist/src/targets/java/unirest/client.js +53 -0
  48. package/dist/src/targets/javascript/axios/client.js +101 -0
  49. package/dist/src/targets/javascript/axios/fixtures/application-form-encoded.js +22 -0
  50. package/dist/src/targets/javascript/axios/fixtures/application-json.js +26 -0
  51. package/dist/src/targets/javascript/axios/fixtures/cookies.js +18 -0
  52. package/dist/src/targets/javascript/axios/fixtures/custom-method.js +14 -0
  53. package/dist/src/targets/javascript/axios/fixtures/full.js +26 -0
  54. package/dist/src/targets/javascript/axios/fixtures/headers.js +18 -0
  55. package/dist/src/targets/javascript/axios/fixtures/http-insecure.js +14 -0
  56. package/dist/src/targets/javascript/axios/fixtures/jsonObj-multiline.js +19 -0
  57. package/dist/src/targets/javascript/axios/fixtures/jsonObj-null-value.js +19 -0
  58. package/dist/src/targets/javascript/axios/fixtures/multipart-data.js +22 -0
  59. package/dist/src/targets/javascript/axios/fixtures/multipart-file.js +21 -0
  60. package/dist/src/targets/javascript/axios/fixtures/multipart-form-data-no-params.js +18 -0
  61. package/dist/src/targets/javascript/axios/fixtures/multipart-form-data.js +21 -0
  62. package/dist/src/targets/javascript/axios/fixtures/nested.js +18 -0
  63. package/dist/src/targets/javascript/axios/fixtures/query-encoded.js +21 -0
  64. package/dist/src/targets/javascript/axios/fixtures/query.js +18 -0
  65. package/dist/src/targets/javascript/axios/fixtures/short.js +14 -0
  66. package/dist/src/targets/javascript/axios/fixtures/text-plain.js +19 -0
  67. package/dist/src/targets/javascript/fetch/client.js +115 -0
  68. package/dist/src/targets/javascript/fetch/fixtures/application-form-encoded.js +9 -0
  69. package/dist/src/targets/javascript/fetch/fixtures/application-json.js +16 -0
  70. package/dist/src/targets/javascript/fetch/fixtures/cookies.js +5 -0
  71. package/dist/src/targets/javascript/fetch/fixtures/custom-method.js +5 -0
  72. package/dist/src/targets/javascript/fetch/fixtures/full.js +13 -0
  73. package/dist/src/targets/javascript/fetch/fixtures/headers.js +8 -0
  74. package/dist/src/targets/javascript/fetch/fixtures/http-insecure.js +5 -0
  75. package/dist/src/targets/javascript/fetch/fixtures/jsonObj-multiline.js +9 -0
  76. package/dist/src/targets/javascript/fetch/fixtures/jsonObj-null-value.js +9 -0
  77. package/dist/src/targets/javascript/fetch/fixtures/multipart-data.js +9 -0
  78. package/dist/src/targets/javascript/fetch/fixtures/multipart-file.js +8 -0
  79. package/dist/src/targets/javascript/fetch/fixtures/multipart-form-data-no-params.js +5 -0
  80. package/dist/src/targets/javascript/fetch/fixtures/multipart-form-data.js +8 -0
  81. package/dist/src/targets/javascript/fetch/fixtures/nested.js +5 -0
  82. package/dist/src/targets/javascript/fetch/fixtures/query-encoded.js +5 -0
  83. package/dist/src/targets/javascript/fetch/fixtures/query.js +5 -0
  84. package/dist/src/targets/javascript/fetch/fixtures/short.js +5 -0
  85. package/dist/src/targets/javascript/fetch/fixtures/text-plain.js +5 -0
  86. package/dist/src/targets/javascript/jquery/client.js +93 -0
  87. package/dist/src/targets/javascript/jquery/fixtures/application-form-encoded.js +17 -0
  88. package/dist/src/targets/javascript/jquery/fixtures/application-json.js +15 -0
  89. package/dist/src/targets/javascript/jquery/fixtures/cookies.js +13 -0
  90. package/dist/src/targets/javascript/jquery/fixtures/custom-method.js +11 -0
  91. package/dist/src/targets/javascript/jquery/fixtures/full.js +18 -0
  92. package/dist/src/targets/javascript/jquery/fixtures/headers.js +15 -0
  93. package/dist/src/targets/javascript/jquery/fixtures/http-insecure.js +11 -0
  94. package/dist/src/targets/javascript/jquery/fixtures/jsonObj-multiline.js +15 -0
  95. package/dist/src/targets/javascript/jquery/fixtures/jsonObj-null-value.js +15 -0
  96. package/dist/src/targets/javascript/jquery/fixtures/multipart-data.js +18 -0
  97. package/dist/src/targets/javascript/jquery/fixtures/multipart-file.js +17 -0
  98. package/dist/src/targets/javascript/jquery/fixtures/multipart-form-data-no-params.js +13 -0
  99. package/dist/src/targets/javascript/jquery/fixtures/multipart-form-data.js +17 -0
  100. package/dist/src/targets/javascript/jquery/fixtures/nested.js +11 -0
  101. package/dist/src/targets/javascript/jquery/fixtures/query-encoded.js +11 -0
  102. package/dist/src/targets/javascript/jquery/fixtures/query.js +11 -0
  103. package/dist/src/targets/javascript/jquery/fixtures/short.js +11 -0
  104. package/dist/src/targets/javascript/jquery/fixtures/text-plain.js +14 -0
  105. package/dist/src/targets/javascript/target.js +21 -0
  106. package/dist/src/targets/javascript/xhr/client.js +90 -0
  107. package/dist/src/targets/javascript/xhr/fixtures/application-form-encoded.js +12 -0
  108. package/dist/src/targets/javascript/xhr/fixtures/application-json.js +31 -0
  109. package/dist/src/targets/javascript/xhr/fixtures/cookies.js +12 -0
  110. package/dist/src/targets/javascript/xhr/fixtures/cors.js +10 -0
  111. package/dist/src/targets/javascript/xhr/fixtures/custom-method.js +11 -0
  112. package/dist/src/targets/javascript/xhr/fixtures/full.js +14 -0
  113. package/dist/src/targets/javascript/xhr/fixtures/headers.js +14 -0
  114. package/dist/src/targets/javascript/xhr/fixtures/http-insecure.js +11 -0
  115. package/dist/src/targets/javascript/xhr/fixtures/jsonObj-multiline.js +14 -0
  116. package/dist/src/targets/javascript/xhr/fixtures/jsonObj-null-value.js +14 -0
  117. package/dist/src/targets/javascript/xhr/fixtures/multipart-data.js +13 -0
  118. package/dist/src/targets/javascript/xhr/fixtures/multipart-file.js +12 -0
  119. package/dist/src/targets/javascript/xhr/fixtures/multipart-form-data-no-params.js +11 -0
  120. package/dist/src/targets/javascript/xhr/fixtures/multipart-form-data.js +12 -0
  121. package/dist/src/targets/javascript/xhr/fixtures/nested.js +11 -0
  122. package/dist/src/targets/javascript/xhr/fixtures/query-encoded.js +11 -0
  123. package/dist/src/targets/javascript/xhr/fixtures/query.js +11 -0
  124. package/dist/src/targets/javascript/xhr/fixtures/short.js +11 -0
  125. package/dist/src/targets/javascript/xhr/fixtures/text-plain.js +12 -0
  126. package/dist/src/targets/kotlin/okhttp/client.js +79 -0
  127. package/dist/src/targets/kotlin/target.js +15 -0
  128. package/dist/src/targets/node/axios/client.js +87 -0
  129. package/dist/src/targets/node/axios/fixtures/application-form-encoded.js +19 -0
  130. package/dist/src/targets/node/axios/fixtures/application-json.js +22 -0
  131. package/dist/src/targets/node/axios/fixtures/cookies.js +14 -0
  132. package/dist/src/targets/node/axios/fixtures/custom-method.js +10 -0
  133. package/dist/src/targets/node/axios/fixtures/full.js +22 -0
  134. package/dist/src/targets/node/axios/fixtures/headers.js +14 -0
  135. package/dist/src/targets/node/axios/fixtures/http-insecure.js +10 -0
  136. package/dist/src/targets/node/axios/fixtures/jsonObj-multiline.js +15 -0
  137. package/dist/src/targets/node/axios/fixtures/jsonObj-null-value.js +15 -0
  138. package/dist/src/targets/node/axios/fixtures/multipart-data.js +15 -0
  139. package/dist/src/targets/node/axios/fixtures/multipart-file.js +15 -0
  140. package/dist/src/targets/node/axios/fixtures/multipart-form-data-no-params.js +14 -0
  141. package/dist/src/targets/node/axios/fixtures/multipart-form-data.js +15 -0
  142. package/dist/src/targets/node/axios/fixtures/nested.js +13 -0
  143. package/dist/src/targets/node/axios/fixtures/query-encoded.js +13 -0
  144. package/dist/src/targets/node/axios/fixtures/query.js +13 -0
  145. package/dist/src/targets/node/axios/fixtures/short.js +10 -0
  146. package/dist/src/targets/node/axios/fixtures/text-plain.js +15 -0
  147. package/dist/src/targets/node/fetch/client.js +149 -0
  148. package/dist/src/targets/node/fetch/fixtures/application-form-encoded.js +15 -0
  149. package/dist/src/targets/node/fetch/fixtures/application-json.js +18 -0
  150. package/dist/src/targets/node/fetch/fixtures/cookies.js +7 -0
  151. package/dist/src/targets/node/fetch/fixtures/custom-method.js +7 -0
  152. package/dist/src/targets/node/fetch/fixtures/full.js +18 -0
  153. package/dist/src/targets/node/fetch/fixtures/headers.js +10 -0
  154. package/dist/src/targets/node/fetch/fixtures/http-insecure.js +7 -0
  155. package/dist/src/targets/node/fetch/fixtures/jsonObj-multiline.js +11 -0
  156. package/dist/src/targets/node/fetch/fixtures/jsonObj-null-value.js +11 -0
  157. package/dist/src/targets/node/fetch/fixtures/multipart-data.js +13 -0
  158. package/dist/src/targets/node/fetch/fixtures/multipart-file.js +12 -0
  159. package/dist/src/targets/node/fetch/fixtures/multipart-form-data-no-params.js +7 -0
  160. package/dist/src/targets/node/fetch/fixtures/multipart-form-data.js +11 -0
  161. package/dist/src/targets/node/fetch/fixtures/nested.js +7 -0
  162. package/dist/src/targets/node/fetch/fixtures/query-encoded.js +7 -0
  163. package/dist/src/targets/node/fetch/fixtures/query.js +7 -0
  164. package/dist/src/targets/node/fetch/fixtures/short.js +7 -0
  165. package/dist/src/targets/node/fetch/fixtures/text-plain.js +7 -0
  166. package/dist/src/targets/node/native/client.js +91 -0
  167. package/dist/src/targets/node/native/fixtures/application-form-encoded.js +24 -0
  168. package/dist/src/targets/node/native/fixtures/application-json.js +30 -0
  169. package/dist/src/targets/node/native/fixtures/cookies.js +22 -0
  170. package/dist/src/targets/node/native/fixtures/custom-method.js +20 -0
  171. package/dist/src/targets/node/native/fixtures/full.js +26 -0
  172. package/dist/src/targets/node/native/fixtures/headers.js +24 -0
  173. package/dist/src/targets/node/native/fixtures/http-insecure.js +20 -0
  174. package/dist/src/targets/node/native/fixtures/jsonObj-multiline.js +23 -0
  175. package/dist/src/targets/node/native/fixtures/jsonObj-null-value.js +23 -0
  176. package/dist/src/targets/node/native/fixtures/multipart-data.js +23 -0
  177. package/dist/src/targets/node/native/fixtures/multipart-file.js +23 -0
  178. package/dist/src/targets/node/native/fixtures/multipart-form-data-no-params.js +22 -0
  179. package/dist/src/targets/node/native/fixtures/multipart-form-data.js +23 -0
  180. package/dist/src/targets/node/native/fixtures/nested.js +20 -0
  181. package/dist/src/targets/node/native/fixtures/query-encoded.js +20 -0
  182. package/dist/src/targets/node/native/fixtures/query.js +20 -0
  183. package/dist/src/targets/node/native/fixtures/short.js +20 -0
  184. package/dist/src/targets/node/native/fixtures/text-plain.js +23 -0
  185. package/dist/src/targets/node/request/client.js +116 -0
  186. package/dist/src/targets/node/request/fixtures/application-form-encoded.js +13 -0
  187. package/dist/src/targets/node/request/fixtures/application-json.js +21 -0
  188. package/dist/src/targets/node/request/fixtures/cookies.js +11 -0
  189. package/dist/src/targets/node/request/fixtures/custom-method.js +8 -0
  190. package/dist/src/targets/node/request/fixtures/full.js +20 -0
  191. package/dist/src/targets/node/request/fixtures/headers.js +12 -0
  192. package/dist/src/targets/node/request/fixtures/http-insecure.js +8 -0
  193. package/dist/src/targets/node/request/fixtures/jsonObj-multiline.js +14 -0
  194. package/dist/src/targets/node/request/fixtures/jsonObj-null-value.js +14 -0
  195. package/dist/src/targets/node/request/fixtures/multipart-data.js +20 -0
  196. package/dist/src/targets/node/request/fixtures/multipart-file.js +19 -0
  197. package/dist/src/targets/node/request/fixtures/multipart-form-data-no-params.js +12 -0
  198. package/dist/src/targets/node/request/fixtures/multipart-form-data.js +13 -0
  199. package/dist/src/targets/node/request/fixtures/nested.js +11 -0
  200. package/dist/src/targets/node/request/fixtures/query-encoded.js +11 -0
  201. package/dist/src/targets/node/request/fixtures/query.js +11 -0
  202. package/dist/src/targets/node/request/fixtures/short.js +8 -0
  203. package/dist/src/targets/node/request/fixtures/text-plain.js +13 -0
  204. package/dist/src/targets/node/target.js +24 -0
  205. package/dist/src/targets/node/unirest/client.js +119 -0
  206. package/dist/src/targets/node/unirest/fixtures/application-form-encoded.js +15 -0
  207. package/dist/src/targets/node/unirest/fixtures/application-json.js +32 -0
  208. package/dist/src/targets/node/unirest/fixtures/cookies.js +12 -0
  209. package/dist/src/targets/node/unirest/fixtures/custom-method.js +8 -0
  210. package/dist/src/targets/node/unirest/fixtures/full.js +27 -0
  211. package/dist/src/targets/node/unirest/fixtures/headers.js +13 -0
  212. package/dist/src/targets/node/unirest/fixtures/http-insecure.js +8 -0
  213. package/dist/src/targets/node/unirest/fixtures/jsonObj-multiline.js +15 -0
  214. package/dist/src/targets/node/unirest/fixtures/jsonObj-null-value.js +15 -0
  215. package/dist/src/targets/node/unirest/fixtures/multipart-data.js +20 -0
  216. package/dist/src/targets/node/unirest/fixtures/multipart-file.js +18 -0
  217. package/dist/src/targets/node/unirest/fixtures/multipart-form-data-no-params.js +11 -0
  218. package/dist/src/targets/node/unirest/fixtures/multipart-form-data.js +16 -0
  219. package/dist/src/targets/node/unirest/fixtures/nested.js +13 -0
  220. package/dist/src/targets/node/unirest/fixtures/query-encoded.js +12 -0
  221. package/dist/src/targets/node/unirest/fixtures/query.js +16 -0
  222. package/dist/src/targets/node/unirest/fixtures/short.js +8 -0
  223. package/dist/src/targets/node/unirest/fixtures/text-plain.js +12 -0
  224. package/dist/src/targets/objc/helpers.js +59 -0
  225. package/dist/src/targets/objc/nsurlsession/client.js +151 -0
  226. package/dist/src/targets/objc/target.js +15 -0
  227. package/dist/src/targets/ocaml/cohttp/client.js +72 -0
  228. package/dist/src/targets/ocaml/target.js +15 -0
  229. package/dist/src/targets/php/curl/client.js +135 -0
  230. package/dist/src/targets/php/guzzle/client.js +126 -0
  231. package/dist/src/targets/php/helpers.js +63 -0
  232. package/dist/src/targets/php/http1/client.js +90 -0
  233. package/dist/src/targets/php/http2/client.js +128 -0
  234. package/dist/src/targets/php/target.js +22 -0
  235. package/dist/src/targets/powershell/common.js +49 -0
  236. package/dist/src/targets/powershell/restmethod/client.js +13 -0
  237. package/dist/src/targets/powershell/target.js +17 -0
  238. package/dist/src/targets/powershell/webrequest/client.js +13 -0
  239. package/dist/src/targets/python/helpers.js +70 -0
  240. package/dist/src/targets/python/requests/client.js +161 -0
  241. package/dist/src/targets/python/target.js +16 -0
  242. package/dist/src/targets/r/httr/client.js +125 -0
  243. package/dist/src/targets/r/target.js +15 -0
  244. package/dist/src/targets/ruby/native/client.js +69 -0
  245. package/dist/src/targets/ruby/target.js +15 -0
  246. package/dist/src/targets/shell/curl/client.js +171 -0
  247. package/dist/src/targets/shell/httpie/client.js +111 -0
  248. package/dist/src/targets/shell/target.js +20 -0
  249. package/dist/src/targets/shell/wget/client.js +55 -0
  250. package/dist/src/targets/swift/helpers.js +80 -0
  251. package/dist/src/targets/swift/nsurlsession/client.js +156 -0
  252. package/dist/src/targets/swift/target.js +15 -0
  253. package/dist/src/targets/targets.js +130 -0
  254. package/package.json +26 -21
  255. package/src/helpers/code-builder.js +0 -108
  256. package/src/helpers/form-data.js +0 -107
  257. package/src/helpers/headers.js +0 -48
  258. package/src/helpers/reducer.js +0 -20
  259. package/src/index.js +0 -361
  260. package/src/targets/c/index.js +0 -10
  261. package/src/targets/c/libcurl.js +0 -45
  262. package/src/targets/clojure/clj_http.js +0 -176
  263. package/src/targets/clojure/index.js +0 -10
  264. package/src/targets/csharp/httpclient.js +0 -157
  265. package/src/targets/csharp/index.js +0 -11
  266. package/src/targets/csharp/restsharp.js +0 -49
  267. package/src/targets/go/index.js +0 -10
  268. package/src/targets/go/native.js +0 -130
  269. package/src/targets/http/http1.1.js +0 -89
  270. package/src/targets/http/index.js +0 -10
  271. package/src/targets/index.js +0 -20
  272. package/src/targets/java/asynchttp.js +0 -54
  273. package/src/targets/java/index.js +0 -13
  274. package/src/targets/java/nethttp.js +0 -59
  275. package/src/targets/java/okhttp.js +0 -78
  276. package/src/targets/java/unirest.js +0 -57
  277. package/src/targets/javascript/axios.js +0 -101
  278. package/src/targets/javascript/fetch.js +0 -129
  279. package/src/targets/javascript/index.js +0 -13
  280. package/src/targets/javascript/jquery.js +0 -89
  281. package/src/targets/javascript/xhr.js +0 -86
  282. package/src/targets/kotlin/index.js +0 -10
  283. package/src/targets/kotlin/okhttp.js +0 -78
  284. package/src/targets/node/axios.js +0 -76
  285. package/src/targets/node/fetch.js +0 -145
  286. package/src/targets/node/index.js +0 -15
  287. package/src/targets/node/native.js +0 -92
  288. package/src/targets/node/request.js +0 -126
  289. package/src/targets/node/unirest.js +0 -120
  290. package/src/targets/objc/helpers.js +0 -80
  291. package/src/targets/objc/index.js +0 -10
  292. package/src/targets/objc/nsurlsession.js +0 -164
  293. package/src/targets/ocaml/cohttp.js +0 -73
  294. package/src/targets/ocaml/index.js +0 -10
  295. package/src/targets/php/curl.js +0 -142
  296. package/src/targets/php/guzzle.js +0 -135
  297. package/src/targets/php/helpers.js +0 -87
  298. package/src/targets/php/http1.js +0 -85
  299. package/src/targets/php/http2.js +0 -131
  300. package/src/targets/php/index.js +0 -14
  301. package/src/targets/powershell/common.js +0 -60
  302. package/src/targets/powershell/index.js +0 -11
  303. package/src/targets/powershell/restmethod.js +0 -8
  304. package/src/targets/powershell/webrequest.js +0 -8
  305. package/src/targets/python/helpers.js +0 -85
  306. package/src/targets/python/index.js +0 -11
  307. package/src/targets/python/requests.js +0 -163
  308. package/src/targets/r/httr.js +0 -134
  309. package/src/targets/r/index.js +0 -10
  310. package/src/targets/ruby/index.js +0 -10
  311. package/src/targets/ruby/native.js +0 -71
  312. package/src/targets/shell/curl.js +0 -157
  313. package/src/targets/shell/helpers.js +0 -23
  314. package/src/targets/shell/httpie.js +0 -129
  315. package/src/targets/shell/index.js +0 -13
  316. package/src/targets/shell/wget.js +0 -52
  317. package/src/targets/swift/helpers.js +0 -93
  318. package/src/targets/swift/index.js +0 -10
  319. package/src/targets/swift/nsurlsession.js +0 -152
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var axios = require('axios')["default"];
3
+ var options = {
4
+ method: 'POST',
5
+ url: 'https://httpbin.org/anything',
6
+ headers: { 'Content-Type': 'multipart/form-data' }
7
+ };
8
+ axios
9
+ .request(options)
10
+ .then(function (response) {
11
+ console.log(response.data);
12
+ })["catch"](function (error) {
13
+ console.error(error);
14
+ });
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var axios = require('axios')["default"];
3
+ var options = {
4
+ method: 'POST',
5
+ url: 'https://httpbin.org/anything',
6
+ headers: { 'Content-Type': 'multipart/form-data; boundary=---011000010111000001101001' },
7
+ data: '-----011000010111000001101001\r\nContent-Disposition: form-data; name="foo"\r\n\r\nbar\r\n-----011000010111000001101001--\r\n'
8
+ };
9
+ axios
10
+ .request(options)
11
+ .then(function (response) {
12
+ console.log(response.data);
13
+ })["catch"](function (error) {
14
+ console.error(error);
15
+ });
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var axios = require('axios')["default"];
3
+ var options = {
4
+ method: 'GET',
5
+ url: 'https://httpbin.org/anything?foo%5Bbar%5D=baz%2Czap&fiz=buz&key=value'
6
+ };
7
+ axios
8
+ .request(options)
9
+ .then(function (response) {
10
+ console.log(response.data);
11
+ })["catch"](function (error) {
12
+ console.error(error);
13
+ });
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var axios = require('axios')["default"];
3
+ var options = {
4
+ method: 'GET',
5
+ url: 'https://httpbin.org/anything?startTime=2019-06-13T19%3A08%3A25.455Z&endTime=2015-09-15T14%3A00%3A12-04%3A00'
6
+ };
7
+ axios
8
+ .request(options)
9
+ .then(function (response) {
10
+ console.log(response.data);
11
+ })["catch"](function (error) {
12
+ console.error(error);
13
+ });
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var axios = require('axios')["default"];
3
+ var options = {
4
+ method: 'GET',
5
+ url: 'https://httpbin.org/anything?foo=bar&foo=baz&baz=abc&key=value'
6
+ };
7
+ axios
8
+ .request(options)
9
+ .then(function (response) {
10
+ console.log(response.data);
11
+ })["catch"](function (error) {
12
+ console.error(error);
13
+ });
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ var axios = require('axios')["default"];
3
+ var options = { method: 'GET', url: 'https://httpbin.org/anything' };
4
+ axios
5
+ .request(options)
6
+ .then(function (response) {
7
+ console.log(response.data);
8
+ })["catch"](function (error) {
9
+ console.error(error);
10
+ });
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var axios = require('axios')["default"];
3
+ var options = {
4
+ method: 'POST',
5
+ url: 'https://httpbin.org/anything',
6
+ headers: { 'content-type': 'text/plain' },
7
+ data: 'Hello World'
8
+ };
9
+ axios
10
+ .request(options)
11
+ .then(function (response) {
12
+ console.log(response.data);
13
+ })["catch"](function (error) {
14
+ console.error(error);
15
+ });
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+ /**
3
+ * @description
4
+ * HTTP code snippet generator for Node.js using node-fetch.
5
+ *
6
+ * @author
7
+ * @hirenoble
8
+ *
9
+ * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author.
10
+ */
11
+ var __assign = (this && this.__assign) || function () {
12
+ __assign = Object.assign || function(t) {
13
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
14
+ s = arguments[i];
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
16
+ t[p] = s[p];
17
+ }
18
+ return t;
19
+ };
20
+ return __assign.apply(this, arguments);
21
+ };
22
+ var __importDefault = (this && this.__importDefault) || function (mod) {
23
+ return (mod && mod.__esModule) ? mod : { "default": mod };
24
+ };
25
+ exports.__esModule = true;
26
+ exports.fetch = void 0;
27
+ var stringify_object_1 = __importDefault(require("stringify-object"));
28
+ var code_builder_1 = require("../../../helpers/code-builder");
29
+ var headers_1 = require("../../../helpers/headers");
30
+ exports.fetch = {
31
+ info: {
32
+ key: 'fetch',
33
+ title: 'Fetch',
34
+ link: 'https://github.com/bitinn/node-fetch',
35
+ description: 'Simplified HTTP node-fetch client'
36
+ },
37
+ convert: function (_a, options) {
38
+ var _b;
39
+ var method = _a.method, fullUrl = _a.fullUrl, postData = _a.postData, headersObj = _a.headersObj, cookies = _a.cookies;
40
+ var opts = __assign({ indent: ' ' }, options);
41
+ var includeFS = false;
42
+ var _c = new code_builder_1.CodeBuilder({ indent: opts.indent }), blank = _c.blank, push = _c.push, join = _c.join, unshift = _c.unshift;
43
+ push("const fetch = require('node-fetch');");
44
+ var url = fullUrl;
45
+ var reqOpts = {
46
+ method: method
47
+ };
48
+ if (Object.keys(headersObj).length) {
49
+ reqOpts.headers = headersObj;
50
+ }
51
+ switch (postData.mimeType) {
52
+ case 'application/x-www-form-urlencoded':
53
+ unshift("const { URLSearchParams } = require('url');");
54
+ push('const encodedParams = new URLSearchParams();');
55
+ blank();
56
+ (_b = postData.params) === null || _b === void 0 ? void 0 : _b.forEach(function (param) {
57
+ push("encodedParams.set('".concat(param.name, "', '").concat(param.value, "');"));
58
+ });
59
+ reqOpts.body = 'encodedParams';
60
+ break;
61
+ case 'application/json':
62
+ if (postData.jsonObj) {
63
+ // Though `fetch` doesn't accept JSON objects in the `body` option we're going to
64
+ // stringify it when we add this into the snippet further down.
65
+ reqOpts.body = postData.jsonObj;
66
+ }
67
+ break;
68
+ case 'multipart/form-data':
69
+ if (!postData.params) {
70
+ break;
71
+ }
72
+ // The `form-data` module automatically adds a `Content-Type` header for `multipart/form-data` content and if we add our own here data won't be correctly transmitted.
73
+ // eslint-disable-next-line no-case-declarations -- We're only using `contentTypeHeader` within this block.
74
+ var contentTypeHeader = (0, headers_1.getHeaderName)(headersObj, 'content-type');
75
+ if (contentTypeHeader) {
76
+ delete headersObj[contentTypeHeader];
77
+ }
78
+ unshift("const FormData = require('form-data');");
79
+ push('const formData = new FormData();');
80
+ blank();
81
+ postData.params.forEach(function (param) {
82
+ if (!param.fileName && !param.fileName && !param.contentType) {
83
+ push("formData.append('".concat(param.name, "', '").concat(param.value, "');"));
84
+ return;
85
+ }
86
+ if (param.fileName) {
87
+ includeFS = true;
88
+ push("formData.append('".concat(param.name, "', fs.createReadStream('").concat(param.fileName, "'));"));
89
+ }
90
+ });
91
+ break;
92
+ default:
93
+ if (postData.text) {
94
+ reqOpts.body = postData.text;
95
+ }
96
+ }
97
+ // construct cookies argument
98
+ if (cookies.length) {
99
+ var cookiesString = cookies
100
+ .map(function (_a) {
101
+ var name = _a.name, value = _a.value;
102
+ return "".concat(encodeURIComponent(name), "=").concat(encodeURIComponent(value));
103
+ })
104
+ .join('; ');
105
+ if (reqOpts.headers) {
106
+ reqOpts.headers.cookie = cookiesString;
107
+ }
108
+ else {
109
+ reqOpts.headers = {};
110
+ reqOpts.headers.cookie = cookiesString;
111
+ }
112
+ }
113
+ blank();
114
+ push("const url = '".concat(url, "';"));
115
+ // If we ultimately don't have any headers to send then we shouldn't add an empty object into the request options.
116
+ if (reqOpts.headers && !Object.keys(reqOpts.headers).length) {
117
+ delete reqOpts.headers;
118
+ }
119
+ var stringifiedOptions = (0, stringify_object_1["default"])(reqOpts, {
120
+ indent: ' ',
121
+ inlineCharacterLimit: 80,
122
+ // The Fetch API body only accepts string parameters, but stringified JSON can be difficult to
123
+ // read, so we keep the object as a literal and use this transform function to wrap the literal
124
+ // in a `JSON.stringify` call.
125
+ transform: function (object, property, originalResult) {
126
+ if (property === 'body' && postData.mimeType === 'application/json') {
127
+ return "JSON.stringify(".concat(originalResult, ")");
128
+ }
129
+ return originalResult;
130
+ }
131
+ });
132
+ push("const options = ".concat(stringifiedOptions, ";"));
133
+ blank();
134
+ if (includeFS) {
135
+ unshift("const fs = require('fs');");
136
+ }
137
+ if (postData.params && postData.mimeType === 'multipart/form-data') {
138
+ push('options.body = formData;');
139
+ blank();
140
+ }
141
+ push('fetch(url, options)');
142
+ push('.then(res => res.json())', 1);
143
+ push('.then(json => console.log(json))', 1);
144
+ push(".catch(err => console.error('error:' + err));", 1);
145
+ return join()
146
+ .replace(/'encodedParams'/, 'encodedParams')
147
+ .replace(/"fs\.createReadStream\(\\"(.+)\\"\)"/, 'fs.createReadStream("$1")');
148
+ }
149
+ };
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var URLSearchParams = require('url').URLSearchParams;
3
+ var fetch = require('node-fetch');
4
+ var encodedParams = new URLSearchParams();
5
+ encodedParams.set('foo', 'bar');
6
+ encodedParams.set('hello', 'world');
7
+ var url = 'https://httpbin.org/anything';
8
+ var options = {
9
+ method: 'POST',
10
+ headers: { 'content-type': 'application/x-www-form-urlencoded' },
11
+ body: encodedParams
12
+ };
13
+ fetch(url, options)
14
+ .then(function (res) { return res.json(); })
15
+ .then(function (json) { return console.log(json); })["catch"](function (err) { return console.error('error:' + err); });
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var fetch = require('node-fetch');
3
+ var url = 'https://httpbin.org/anything';
4
+ var options = {
5
+ method: 'POST',
6
+ headers: { 'content-type': 'application/json' },
7
+ body: JSON.stringify({
8
+ number: 1,
9
+ string: 'f"oo',
10
+ arr: [1, 2, 3],
11
+ nested: { a: 'b' },
12
+ arr_mix: [1, 'a', { arr_mix_nested: {} }],
13
+ boolean: false
14
+ })
15
+ };
16
+ fetch(url, options)
17
+ .then(function (res) { return res.json(); })
18
+ .then(function (json) { return console.log(json); })["catch"](function (err) { return console.error('error:' + err); });
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ var fetch = require('node-fetch');
3
+ var url = 'https://httpbin.org/cookies';
4
+ var options = { method: 'GET', headers: { cookie: 'foo=bar; bar=baz' } };
5
+ fetch(url, options)
6
+ .then(function (res) { return res.json(); })
7
+ .then(function (json) { return console.log(json); })["catch"](function (err) { return console.error('error:' + err); });
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ var fetch = require('node-fetch');
3
+ var url = 'https://httpbin.org/anything';
4
+ var options = { method: 'PROPFIND' };
5
+ fetch(url, options)
6
+ .then(function (res) { return res.json(); })
7
+ .then(function (json) { return console.log(json); })["catch"](function (err) { return console.error('error:' + err); });
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var URLSearchParams = require('url').URLSearchParams;
3
+ var fetch = require('node-fetch');
4
+ var encodedParams = new URLSearchParams();
5
+ encodedParams.set('foo', 'bar');
6
+ var url = 'https://httpbin.org/anything?foo=bar&foo=baz&baz=abc&key=value';
7
+ var options = {
8
+ method: 'POST',
9
+ headers: {
10
+ accept: 'application/json',
11
+ 'content-type': 'application/x-www-form-urlencoded',
12
+ cookie: 'foo=bar; bar=baz'
13
+ },
14
+ body: encodedParams
15
+ };
16
+ fetch(url, options)
17
+ .then(function (res) { return res.json(); })
18
+ .then(function (json) { return console.log(json); })["catch"](function (err) { return console.error('error:' + err); });
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ var fetch = require('node-fetch');
3
+ var url = 'https://httpbin.org/headers';
4
+ var options = {
5
+ method: 'GET',
6
+ headers: { accept: 'application/json', 'x-foo': 'Bar', 'x-bar': 'Foo' }
7
+ };
8
+ fetch(url, options)
9
+ .then(function (res) { return res.json(); })
10
+ .then(function (json) { return console.log(json); })["catch"](function (err) { return console.error('error:' + err); });
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ var fetch = require('node-fetch');
3
+ var url = 'http://httpbin.org/anything';
4
+ var options = { method: 'GET' };
5
+ fetch(url, options)
6
+ .then(function (res) { return res.json(); })
7
+ .then(function (json) { return console.log(json); })["catch"](function (err) { return console.error('error:' + err); });
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ var fetch = require('node-fetch');
3
+ var url = 'https://httpbin.org/anything';
4
+ var options = {
5
+ method: 'POST',
6
+ headers: { 'content-type': 'application/json' },
7
+ body: JSON.stringify({ foo: 'bar' })
8
+ };
9
+ fetch(url, options)
10
+ .then(function (res) { return res.json(); })
11
+ .then(function (json) { return console.log(json); })["catch"](function (err) { return console.error('error:' + err); });
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ var fetch = require('node-fetch');
3
+ var url = 'https://httpbin.org/anything';
4
+ var options = {
5
+ method: 'POST',
6
+ headers: { 'content-type': 'application/json' },
7
+ body: JSON.stringify({ foo: null })
8
+ };
9
+ fetch(url, options)
10
+ .then(function (res) { return res.json(); })
11
+ .then(function (json) { return console.log(json); })["catch"](function (err) { return console.error('error:' + err); });
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var fs = require('fs');
3
+ var FormData = require('form-data');
4
+ var fetch = require('node-fetch');
5
+ var formData = new FormData();
6
+ formData.append('foo', fs.createReadStream('src/fixtures/files/hello.txt'));
7
+ formData.append('bar', 'Bonjour le monde');
8
+ var url = 'https://httpbin.org/anything';
9
+ var options = { method: 'POST' };
10
+ options.body = formData;
11
+ fetch(url, options)
12
+ .then(function (res) { return res.json(); })
13
+ .then(function (json) { return console.log(json); })["catch"](function (err) { return console.error('error:' + err); });
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ var fs = require('fs');
3
+ var FormData = require('form-data');
4
+ var fetch = require('node-fetch');
5
+ var formData = new FormData();
6
+ formData.append('foo', fs.createReadStream('src/fixtures/files/hello.txt'));
7
+ var url = 'https://httpbin.org/anything';
8
+ var options = { method: 'POST' };
9
+ options.body = formData;
10
+ fetch(url, options)
11
+ .then(function (res) { return res.json(); })
12
+ .then(function (json) { return console.log(json); })["catch"](function (err) { return console.error('error:' + err); });
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ var fetch = require('node-fetch');
3
+ var url = 'https://httpbin.org/anything';
4
+ var options = { method: 'POST', headers: { 'Content-Type': 'multipart/form-data' } };
5
+ fetch(url, options)
6
+ .then(function (res) { return res.json(); })
7
+ .then(function (json) { return console.log(json); })["catch"](function (err) { return console.error('error:' + err); });
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ var FormData = require('form-data');
3
+ var fetch = require('node-fetch');
4
+ var formData = new FormData();
5
+ formData.append('foo', 'bar');
6
+ var url = 'https://httpbin.org/anything';
7
+ var options = { method: 'POST' };
8
+ options.body = formData;
9
+ fetch(url, options)
10
+ .then(function (res) { return res.json(); })
11
+ .then(function (json) { return console.log(json); })["catch"](function (err) { return console.error('error:' + err); });
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ var fetch = require('node-fetch');
3
+ var url = 'https://httpbin.org/anything?foo%5Bbar%5D=baz%2Czap&fiz=buz&key=value';
4
+ var options = { method: 'GET' };
5
+ fetch(url, options)
6
+ .then(function (res) { return res.json(); })
7
+ .then(function (json) { return console.log(json); })["catch"](function (err) { return console.error('error:' + err); });
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ var fetch = require('node-fetch');
3
+ var url = 'https://httpbin.org/anything?startTime=2019-06-13T19%3A08%3A25.455Z&endTime=2015-09-15T14%3A00%3A12-04%3A00';
4
+ var options = { method: 'GET' };
5
+ fetch(url, options)
6
+ .then(function (res) { return res.json(); })
7
+ .then(function (json) { return console.log(json); })["catch"](function (err) { return console.error('error:' + err); });
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ var fetch = require('node-fetch');
3
+ var url = 'https://httpbin.org/anything?foo=bar&foo=baz&baz=abc&key=value';
4
+ var options = { method: 'GET' };
5
+ fetch(url, options)
6
+ .then(function (res) { return res.json(); })
7
+ .then(function (json) { return console.log(json); })["catch"](function (err) { return console.error('error:' + err); });
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ var fetch = require('node-fetch');
3
+ var url = 'https://httpbin.org/anything';
4
+ var options = { method: 'GET' };
5
+ fetch(url, options)
6
+ .then(function (res) { return res.json(); })
7
+ .then(function (json) { return console.log(json); })["catch"](function (err) { return console.error('error:' + err); });
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ var fetch = require('node-fetch');
3
+ var url = 'https://httpbin.org/anything';
4
+ var options = { method: 'POST', headers: { 'content-type': 'text/plain' }, body: 'Hello World' };
5
+ fetch(url, options)
6
+ .then(function (res) { return res.json(); })
7
+ .then(function (json) { return console.log(json); })["catch"](function (err) { return console.error('error:' + err); });
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ /**
3
+ * @description
4
+ * HTTP code snippet generator for native Node.js.
5
+ *
6
+ * @author
7
+ * @AhmadNassri
8
+ *
9
+ * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author.
10
+ */
11
+ var __assign = (this && this.__assign) || function () {
12
+ __assign = Object.assign || function(t) {
13
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
14
+ s = arguments[i];
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
16
+ t[p] = s[p];
17
+ }
18
+ return t;
19
+ };
20
+ return __assign.apply(this, arguments);
21
+ };
22
+ var __importDefault = (this && this.__importDefault) || function (mod) {
23
+ return (mod && mod.__esModule) ? mod : { "default": mod };
24
+ };
25
+ exports.__esModule = true;
26
+ exports.native = void 0;
27
+ var stringify_object_1 = __importDefault(require("stringify-object"));
28
+ var code_builder_1 = require("../../../helpers/code-builder");
29
+ exports.native = {
30
+ info: {
31
+ key: 'native',
32
+ title: 'HTTP',
33
+ link: 'http://nodejs.org/api/http.html#http_http_request_options_callback',
34
+ description: 'Node.js native HTTP interface'
35
+ },
36
+ convert: function (_a, options) {
37
+ var _b;
38
+ var uriObj = _a.uriObj, method = _a.method, allHeaders = _a.allHeaders, postData = _a.postData;
39
+ var opts = __assign({ indent: ' ' }, options);
40
+ var _c = new code_builder_1.CodeBuilder({ indent: opts.indent }), blank = _c.blank, join = _c.join, push = _c.push, unshift = _c.unshift;
41
+ var reqOpts = {
42
+ method: method,
43
+ hostname: uriObj.hostname,
44
+ port: uriObj.port,
45
+ path: uriObj.path,
46
+ headers: allHeaders
47
+ };
48
+ push("const http = require('".concat((_b = uriObj.protocol) === null || _b === void 0 ? void 0 : _b.replace(':', ''), "');"));
49
+ blank();
50
+ push("const options = ".concat((0, stringify_object_1["default"])(reqOpts, { indent: opts.indent }), ";"));
51
+ blank();
52
+ push('const req = http.request(options, function (res) {');
53
+ push('const chunks = [];', 1);
54
+ blank();
55
+ push("res.on('data', function (chunk) {", 1);
56
+ push('chunks.push(chunk);', 2);
57
+ push('});', 1);
58
+ blank();
59
+ push("res.on('end', function () {", 1);
60
+ push('const body = Buffer.concat(chunks);', 2);
61
+ push('console.log(body.toString());', 2);
62
+ push('});', 1);
63
+ push('});');
64
+ blank();
65
+ switch (postData.mimeType) {
66
+ case 'application/x-www-form-urlencoded':
67
+ if (postData.paramsObj) {
68
+ unshift("const qs = require('querystring');");
69
+ push("req.write(qs.stringify(".concat((0, stringify_object_1["default"])(postData.paramsObj, {
70
+ indent: ' ',
71
+ inlineCharacterLimit: 80
72
+ }), "));"));
73
+ }
74
+ break;
75
+ case 'application/json':
76
+ if (postData.jsonObj) {
77
+ push("req.write(JSON.stringify(".concat((0, stringify_object_1["default"])(postData.jsonObj, {
78
+ indent: ' ',
79
+ inlineCharacterLimit: 80
80
+ }), "));"));
81
+ }
82
+ break;
83
+ default:
84
+ if (postData.text) {
85
+ push("req.write(".concat((0, stringify_object_1["default"])(postData.text, { indent: opts.indent }), ");"));
86
+ }
87
+ }
88
+ push('req.end();');
89
+ return join();
90
+ }
91
+ };
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var qs = require('querystring');
3
+ var http = require('https');
4
+ var options = {
5
+ method: 'POST',
6
+ hostname: 'httpbin.org',
7
+ port: null,
8
+ path: '/anything',
9
+ headers: {
10
+ 'content-type': 'application/x-www-form-urlencoded'
11
+ }
12
+ };
13
+ var req = http.request(options, function (res) {
14
+ var chunks = [];
15
+ res.on('data', function (chunk) {
16
+ chunks.push(chunk);
17
+ });
18
+ res.on('end', function () {
19
+ var body = Buffer.concat(chunks);
20
+ console.log(body.toString());
21
+ });
22
+ });
23
+ req.write(qs.stringify({ foo: 'bar', hello: 'world' }));
24
+ req.end();
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var http = require('https');
3
+ var options = {
4
+ method: 'POST',
5
+ hostname: 'httpbin.org',
6
+ port: null,
7
+ path: '/anything',
8
+ headers: {
9
+ 'content-type': 'application/json'
10
+ }
11
+ };
12
+ var req = http.request(options, function (res) {
13
+ var chunks = [];
14
+ res.on('data', function (chunk) {
15
+ chunks.push(chunk);
16
+ });
17
+ res.on('end', function () {
18
+ var body = Buffer.concat(chunks);
19
+ console.log(body.toString());
20
+ });
21
+ });
22
+ req.write(JSON.stringify({
23
+ number: 1,
24
+ string: 'f"oo',
25
+ arr: [1, 2, 3],
26
+ nested: { a: 'b' },
27
+ arr_mix: [1, 'a', { arr_mix_nested: {} }],
28
+ boolean: false
29
+ }));
30
+ req.end();
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var http = require('https');
3
+ var options = {
4
+ method: 'GET',
5
+ hostname: 'httpbin.org',
6
+ port: null,
7
+ path: '/cookies',
8
+ headers: {
9
+ cookie: 'foo=bar; bar=baz'
10
+ }
11
+ };
12
+ var req = http.request(options, function (res) {
13
+ var chunks = [];
14
+ res.on('data', function (chunk) {
15
+ chunks.push(chunk);
16
+ });
17
+ res.on('end', function () {
18
+ var body = Buffer.concat(chunks);
19
+ console.log(body.toString());
20
+ });
21
+ });
22
+ req.end();