Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Commit

Permalink
Merge branch 'release/1.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
steffans committed Feb 5, 2017
2 parents 37df5c7 + e50222e commit f8377d5
Show file tree
Hide file tree
Showing 16 changed files with 256 additions and 51 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ $ bower install vue-resource
```

### CDN
Available on [jsdelivr](https://cdn.jsdelivr.net/vue.resource/1.1.2/vue-resource.min.js), [cdnjs](https://cdnjs.com/libraries/vue-resource) or [unpkg](https://unpkg.com/vue-resource@1.1.2/dist/vue-resource.min.js).
Available on [jsdelivr](https://cdn.jsdelivr.net/vue.resource/1.2.0/vue-resource.min.js), [cdnjs](https://cdnjs.com/libraries/vue-resource) or [unpkg](https://unpkg.com/vue-resource@1.2.0/dist/vue-resource.min.js).
```html
<script src="https://cdn.jsdelivr.net/vue.resource/1.1.2/vue-resource.min.js"></script>
<script src="https://cdn.jsdelivr.net/vue.resource/1.2.0/vue-resource.min.js"></script>
```

## Example
Expand Down
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "vue-resource",
"main": "dist/vue-resource.js",
"version": "1.1.2",
"version": "1.2.0",
"description": "The HTTP client for Vue.js",
"homepage": "https://github.com/vuejs/vue-resource",
"homepage": "https://github.com/pagekit/vue-resource",
"license": "MIT",
"keywords": [
"vue",
Expand Down
2 changes: 1 addition & 1 deletion build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var package = require('../package.json');
var banner =
"/*!\n" +
" * vue-resource v" + package.version + "\n" +
" * https://github.com/vuejs/vue-resource\n" +
" * https://github.com/pagekit/vue-resource\n" +
" * Released under the MIT License.\n" +
" */\n";

Expand Down
56 changes: 48 additions & 8 deletions dist/vue-resource.common.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* vue-resource v1.1.2
* https://github.com/vuejs/vue-resource
* vue-resource v1.2.0
* https://github.com/pagekit/vue-resource
* Released under the MIT License.
*/

Expand Down Expand Up @@ -888,7 +888,7 @@ function isJson(str) {
}

/**
* JSONP client.
* JSONP client (Browser).
*/

var jsonpClient = function (request) {
Expand Down Expand Up @@ -1002,7 +1002,7 @@ var header = function (request, next) {
};

/**
* XMLHttp client.
* XMLHttp client (Browser).
*/

var SUPPORTS_BLOB = typeof Blob !== 'undefined' && typeof FileReader !== 'undefined';
Expand Down Expand Up @@ -1046,6 +1046,10 @@ var xhrClient = function (request) {
xhr.withCredentials = true;
}

if (!request.crossOrigin) {
request.headers.set('X-Requested-With', 'XMLHttpRequest');
}

if ('responseType' in xhr && SUPPORTS_BLOB) {
xhr.responseType = 'blob';
}
Expand All @@ -1062,6 +1066,43 @@ var xhrClient = function (request) {
});
};

/**
* Http client (Node).
*/

var nodeClient = function (request) {

var client = require('got');

return new PromiseObj(function (resolve) {

var url = request.getUrl();
var body = request.getBody();
var method = request.method;
var headers = {}, handler;

request.headers.forEach(function (value, name) {
headers[name] = value;
});

client(url, {body: body, method: method, headers: headers}).then(handler = function (resp) {

var response = request.respondWith(resp.body, {
status: resp.statusCode,
statusText: trim(resp.statusMessage)
}
);

each(resp.headers, function (value, name) {
response.headers.set(name, value);
});

resolve(response);

}, function (error$$1) { return handler(error$$1.response); });
});
};

/**
* Base client.
*/
Expand Down Expand Up @@ -1125,7 +1166,7 @@ var Client = function (context) {

function sendRequest(request, resolve) {

var client = request.client || xhrClient;
var client = request.client || (inBrowser ? xhrClient : nodeClient);

resolve(client(request));
}
Expand Down Expand Up @@ -1299,7 +1340,6 @@ Request.prototype.respondWith = function respondWith (body, options$$1) {
* Service for sending network requests.
*/

var CUSTOM_HEADERS = {'X-Requested-With': 'XMLHttpRequest'};
var COMMON_HEADERS = {'Accept': 'application/json, text/plain, */*'};
var JSON_CONTENT_TYPE = {'Content-Type': 'application/json;charset=utf-8'};

Expand Down Expand Up @@ -1334,8 +1374,8 @@ Http.headers = {
post: JSON_CONTENT_TYPE,
patch: JSON_CONTENT_TYPE,
delete: JSON_CONTENT_TYPE,
custom: CUSTOM_HEADERS,
common: COMMON_HEADERS
common: COMMON_HEADERS,
custom: {}
};

Http.interceptors = [before, method, body, jsonp, header, cors];
Expand Down
56 changes: 48 additions & 8 deletions dist/vue-resource.es2015.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* vue-resource v1.1.2
* https://github.com/vuejs/vue-resource
* vue-resource v1.2.0
* https://github.com/pagekit/vue-resource
* Released under the MIT License.
*/

Expand Down Expand Up @@ -886,7 +886,7 @@ function isJson(str) {
}

/**
* JSONP client.
* JSONP client (Browser).
*/

var jsonpClient = function (request) {
Expand Down Expand Up @@ -1000,7 +1000,7 @@ var header = function (request, next) {
};

/**
* XMLHttp client.
* XMLHttp client (Browser).
*/

var SUPPORTS_BLOB = typeof Blob !== 'undefined' && typeof FileReader !== 'undefined';
Expand Down Expand Up @@ -1044,6 +1044,10 @@ var xhrClient = function (request) {
xhr.withCredentials = true;
}

if (!request.crossOrigin) {
request.headers.set('X-Requested-With', 'XMLHttpRequest');
}

if ('responseType' in xhr && SUPPORTS_BLOB) {
xhr.responseType = 'blob';
}
Expand All @@ -1060,6 +1064,43 @@ var xhrClient = function (request) {
});
};

/**
* Http client (Node).
*/

var nodeClient = function (request) {

var client = require('got');

return new PromiseObj(function (resolve) {

var url = request.getUrl();
var body = request.getBody();
var method = request.method;
var headers = {}, handler;

request.headers.forEach(function (value, name) {
headers[name] = value;
});

client(url, {body: body, method: method, headers: headers}).then(handler = function (resp) {

var response = request.respondWith(resp.body, {
status: resp.statusCode,
statusText: trim(resp.statusMessage)
}
);

each(resp.headers, function (value, name) {
response.headers.set(name, value);
});

resolve(response);

}, function (error$$1) { return handler(error$$1.response); });
});
};

/**
* Base client.
*/
Expand Down Expand Up @@ -1123,7 +1164,7 @@ var Client = function (context) {

function sendRequest(request, resolve) {

var client = request.client || xhrClient;
var client = request.client || (inBrowser ? xhrClient : nodeClient);

resolve(client(request));
}
Expand Down Expand Up @@ -1297,7 +1338,6 @@ Request.prototype.respondWith = function respondWith (body, options$$1) {
* Service for sending network requests.
*/

var CUSTOM_HEADERS = {'X-Requested-With': 'XMLHttpRequest'};
var COMMON_HEADERS = {'Accept': 'application/json, text/plain, */*'};
var JSON_CONTENT_TYPE = {'Content-Type': 'application/json;charset=utf-8'};

Expand Down Expand Up @@ -1332,8 +1372,8 @@ Http.headers = {
post: JSON_CONTENT_TYPE,
patch: JSON_CONTENT_TYPE,
delete: JSON_CONTENT_TYPE,
custom: CUSTOM_HEADERS,
common: COMMON_HEADERS
common: COMMON_HEADERS,
custom: {}
};

Http.interceptors = [before, method, body, jsonp, header, cors];
Expand Down
56 changes: 48 additions & 8 deletions dist/vue-resource.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* vue-resource v1.1.2
* https://github.com/vuejs/vue-resource
* vue-resource v1.2.0
* https://github.com/pagekit/vue-resource
* Released under the MIT License.
*/

Expand Down Expand Up @@ -892,7 +892,7 @@ function isJson(str) {
}

/**
* JSONP client.
* JSONP client (Browser).
*/

var jsonpClient = function (request) {
Expand Down Expand Up @@ -1006,7 +1006,7 @@ var header = function (request, next) {
};

/**
* XMLHttp client.
* XMLHttp client (Browser).
*/

var SUPPORTS_BLOB = typeof Blob !== 'undefined' && typeof FileReader !== 'undefined';
Expand Down Expand Up @@ -1050,6 +1050,10 @@ var xhrClient = function (request) {
xhr.withCredentials = true;
}

if (!request.crossOrigin) {
request.headers.set('X-Requested-With', 'XMLHttpRequest');
}

if ('responseType' in xhr && SUPPORTS_BLOB) {
xhr.responseType = 'blob';
}
Expand All @@ -1066,6 +1070,43 @@ var xhrClient = function (request) {
});
};

/**
* Http client (Node).
*/

var nodeClient = function (request) {

var client = require('got');

return new PromiseObj(function (resolve) {

var url = request.getUrl();
var body = request.getBody();
var method = request.method;
var headers = {}, handler;

request.headers.forEach(function (value, name) {
headers[name] = value;
});

client(url, {body: body, method: method, headers: headers}).then(handler = function (resp) {

var response = request.respondWith(resp.body, {
status: resp.statusCode,
statusText: trim(resp.statusMessage)
}
);

each(resp.headers, function (value, name) {
response.headers.set(name, value);
});

resolve(response);

}, function (error$$1) { return handler(error$$1.response); });
});
};

/**
* Base client.
*/
Expand Down Expand Up @@ -1129,7 +1170,7 @@ var Client = function (context) {

function sendRequest(request, resolve) {

var client = request.client || xhrClient;
var client = request.client || (inBrowser ? xhrClient : nodeClient);

resolve(client(request));
}
Expand Down Expand Up @@ -1303,7 +1344,6 @@ Request.prototype.respondWith = function respondWith (body, options$$1) {
* Service for sending network requests.
*/

var CUSTOM_HEADERS = {'X-Requested-With': 'XMLHttpRequest'};
var COMMON_HEADERS = {'Accept': 'application/json, text/plain, */*'};
var JSON_CONTENT_TYPE = {'Content-Type': 'application/json;charset=utf-8'};

Expand Down Expand Up @@ -1338,8 +1378,8 @@ Http.headers = {
post: JSON_CONTENT_TYPE,
patch: JSON_CONTENT_TYPE,
delete: JSON_CONTENT_TYPE,
custom: CUSTOM_HEADERS,
common: COMMON_HEADERS
common: COMMON_HEADERS,
custom: {}
};

Http.interceptors = [before, method, body, jsonp, header, cors];
Expand Down
Loading

0 comments on commit f8377d5

Please sign in to comment.