httpsnippet
Advanced tools
Comparing version 1.0.0-beta.8 to 1.0.0-beta.9
{ | ||
"version": "1.0.0-beta.8", | ||
"version": "1.0.0-beta.9", | ||
"name": "httpsnippet", | ||
@@ -4,0 +4,0 @@ "description": "HTTP Request snippet generator for *most* languages", |
'use strict'; | ||
var util = require('util'); | ||
var reducer = require('.,/../../reducer'); | ||
var reducer = require('../../reducer'); | ||
@@ -66,6 +66,15 @@ module.exports = function (options) { | ||
if (!this.source.postData.text && this.source.postData.params) { | ||
var postData = this.source.postData.params.reduce(reducer, {}); | ||
if (this.source.postData.mimeType === 'application/x-www-form-urlencoded') { | ||
var postData = this.source.postData.params.reduce(reducer, {}); | ||
code.push(util.format('var postData = querystring.stringify(%s);', JSON.stringify(postData))); | ||
code.push(util.format('req.write(postData);')); | ||
code.push(util.format('var postData = querystring.stringify(%s);', JSON.stringify(postData))); | ||
code.push(util.format('req.write(postData);')); | ||
} | ||
if (this.source.postData.mimeType === 'multipart/form-data') { | ||
postData = this.source.postData.params.reduce(reducer, {}); | ||
code.push(util.format('var postData = querystring.stringify(%s);', JSON.stringify(postData))); | ||
code.push(util.format('req.write(postData);')); | ||
} | ||
} | ||
@@ -72,0 +81,0 @@ |
'use strict'; | ||
var util = require('util'); | ||
module.exports = function (options) { | ||
var opts = util._extend({ | ||
timeout: '10' | ||
}, options); | ||
var code = []; | ||
@@ -14,3 +20,3 @@ | ||
code.push(' cachePolicy:NSURLRequestUseProtocolCachePolicy'); | ||
code.push(' timeoutInterval:10.0];'); | ||
code.push(' timeoutInterval:' + parseInt(opts.timeout, 10).toFixed(1) + '];'); | ||
code.push('[request setHTTPMethod:@"' + this.source.method + '"];'); | ||
@@ -32,3 +38,3 @@ | ||
// Set request body | ||
if (this.source.postData && this.source.postData.params || this.source.postData.text) { | ||
if (this.source.postData && (this.source.postData.params || this.source.postData.text)) { | ||
code.push(null); | ||
@@ -35,0 +41,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44029
25
705