Last change
on this file since 525 was
525,
checked in by hendrikvanantwerpen, 11 years ago
|
- Allow empty subcodes.
- Use HTTPResult exclusively on server (no more q).
- Set readonly & disabled on ourselves as well in _ComplexValueMixin
- Split server into several modules.
- Check codes on the variable level, not question level.
- We can add modules in design documents now.
|
File size:
513 bytes
|
Rev | Line | |
---|
[525] | 1 | var HTTPResult = require('./http-result') |
---|
| 2 | , request = require('request') |
---|
| 3 | , url = require('url') |
---|
| 4 | , _ = require('underscore') |
---|
| 5 | ; |
---|
| 6 | |
---|
| 7 | module.exports = function(url, options) { |
---|
| 8 | |
---|
| 9 | var result = new HTTPResult(); |
---|
| 10 | |
---|
| 11 | options = options ? _.clone(options) : {}; |
---|
| 12 | options.uri = url || options.uri; |
---|
| 13 | |
---|
| 14 | request(options,function(err,res,body){ |
---|
| 15 | if ( err ) { |
---|
| 16 | result.set(-1,err); |
---|
| 17 | } else { |
---|
| 18 | result.set(res.statusCode,body); |
---|
| 19 | } |
---|
| 20 | }); |
---|
| 21 | |
---|
| 22 | return result; |
---|
| 23 | |
---|
| 24 | }; |
---|
Note: See
TracBrowser
for help on using the repository browser.