Comparing version 0.5.1 to 0.5.2
0.5.2 / 2013-09-23 | ||
================== | ||
* add JSONResponseFormatError; append request url infomation to err.message | ||
0.5.1 / 2013-08-23 | ||
@@ -3,0 +8,0 @@ ================== |
@@ -193,2 +193,5 @@ /** | ||
callback = null; | ||
if (err) { | ||
err.message += ', ' + options.method + ' ' + url; | ||
} | ||
cb(err, data, res); | ||
@@ -295,2 +298,5 @@ }; | ||
} catch (e) { | ||
if (e.name === 'SyntaxError') { | ||
e.name = 'JSONResponseFormatError'; | ||
} | ||
err = e; | ||
@@ -297,0 +303,0 @@ } |
{ | ||
"name": "urllib", | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"description": "Help in opening URLs (mostly HTTP) in a complex world — basic and digest authentication, redirections, cookies and more.", | ||
@@ -5,0 +5,0 @@ "keywords": [ "urllib", "http", "urlopen", "curl", "wget", "request", "https" ], |
@@ -98,6 +98,8 @@ # urllib | ||
if `Content-Type` header is not set. | ||
If `Content-type` is `application/json`, the `data` will be `JSON.stringify` to JSON data format. | ||
#### `options.content` | ||
`options.content` is useful when you wish to construct the request body by yourself, for example making a `Content-Type: application/json` request. | ||
`options.content` is useful when you wish to construct the request body by yourself, | ||
for example making a `Content-Type: application/json` request. | ||
@@ -113,4 +115,4 @@ Notes that if you want to send a JSON body, you should stringify it yourself: | ||
content: JSON.stringify({ | ||
'a': 'hello', | ||
'b': 'world' | ||
a: 'hello', | ||
b: 'world' | ||
}) | ||
@@ -133,2 +135,17 @@ }); | ||
This exmaple can use `options.data` with `application/json` content type: | ||
```js | ||
urllib.request('http://example.com', { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
data: { | ||
a: 'hello', | ||
b: 'world' | ||
} | ||
}); | ||
``` | ||
#### `options.stream` | ||
@@ -150,3 +167,3 @@ | ||
stream: form | ||
}, function (err, data) { | ||
}, function (err, data, res) { | ||
// upload finished | ||
@@ -153,0 +170,0 @@ }); |
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
26830
311
250