Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit e8d1e7c

Browse files
authored
fix: fix the passThru feature which wasn’t implemented properly in v0.4.0 (#134)
closes #133
1 parent 403f932 commit e8d1e7c

18 files changed

+425
-162
lines changed

CHANGELOG.md

+13-2
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,23 @@ We do try to tell you about such changes in this `CHANGELOG.md`
99

1010
and we fix bugs as fast as we can.
1111

12+
<a id="0.4.1"></a>
13+
## 0.4.1 (2017-09-08)
14+
**Support PassThru.**
15+
16+
The passthru feature was broken by 0.4.0
17+
- add passthru to both `Http` and `HttpClient`
18+
- test passThru feature with jasmine-ajax mock-ajax plugin
19+
to intercept Angular's attempt to call browser's XHR
20+
- update devDependency packages
21+
- update karma.conf with jasmine-ajax plugin
22+
1223
<a id="0.4.0"></a>
13-
## 0.4.0 (2017-09-08)
24+
## 0.4.0 (2017-09-07)
1425
**Theme: Support `HttpClient` and add tests**.
1526
See PR #130.
1627

17-
BREAKING CHANGES: Massive refactoring.
28+
**BREAKING CHANGES**: Massive refactoring.
1829
Many low-level and customization options have changed.
1930
Apps that stuck with defaults should be (mostly) OK.
2031

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ compiling your application project.
385385

386386
- `npm run build` to confirm the project compiles w/o error (sanity check)
387387

388-
- `npm test` to build and run tests (see "Testing" below)
388+
- `npm test` to build and run tests (see ["Testing"](#testing) below)
389389

390390
- `gulp build`
391391
- commit and push

backend.service.js

+4-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend.service.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundles/in-memory-web-api.umd.js

+23-27
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,6 @@ var BackendService = (function () {
578578
this.config.host = loc.host; // default to app web server host
579579
this.config.rootPath = loc.path; // default to path when app is served (e.g.'/')
580580
Object.assign(this.config, config);
581-
this.setPassThruBackend();
582581
}
583582
//// protected /////
584583
/**
@@ -647,8 +646,11 @@ var BackendService = (function () {
647646
// request is for a collection created by the InMemoryDbService
648647
return this.createResponse$(function () { return _this.collectionHandler(reqInfo); });
649648
}
650-
else if (this.passThruBackend) {
649+
else if (this.config.passThruUnknownUrl) {
651650
// Passes request thru to a "real" backend.
651+
if (!this.passThruBackend) {
652+
this.setPassThruBackend();
653+
}
652654
return this.passThruBackend.handle(req);
653655
}
654656
else {
@@ -1156,22 +1158,19 @@ var HttpBackendService = (function (_super) {
11561158
});
11571159
};
11581160
HttpBackendService.prototype.setPassThruBackend = function () {
1159-
this.passThruBackend = undefined;
1160-
if (this.config.passThruUnknownUrl) {
1161-
try {
1162-
// copied from @angular/http/backends/xhr_backend
1163-
var browserXhr = this.injector.get(_angular_http.BrowserXhr);
1164-
var baseResponseOptions = this.injector.get(_angular_http.ResponseOptions);
1165-
var xsrfStrategy = this.injector.get(_angular_http.XSRFStrategy);
1166-
var xhrBackend_1 = new _angular_http.XHRBackend(browserXhr, baseResponseOptions, xsrfStrategy);
1167-
this.passThruBackend = {
1168-
handle: function (req) { return xhrBackend_1.createConnection(req).response; }
1169-
};
1170-
}
1171-
catch (e) {
1172-
e.message = 'Cannot create passThru404 backend; ' + (e.message || '');
1173-
throw e;
1174-
}
1161+
try {
1162+
// copied from @angular/http/backends/xhr_backend
1163+
var browserXhr = this.injector.get(_angular_http.BrowserXhr);
1164+
var baseResponseOptions = this.injector.get(_angular_http.ResponseOptions);
1165+
var xsrfStrategy = this.injector.get(_angular_http.XSRFStrategy);
1166+
var xhrBackend_1 = new _angular_http.XHRBackend(browserXhr, baseResponseOptions, xsrfStrategy);
1167+
this.passThruBackend = {
1168+
handle: function (req) { return xhrBackend_1.createConnection(req).response; }
1169+
};
1170+
}
1171+
catch (e) {
1172+
e.message = 'Cannot create passThru404 backend; ' + (e.message || '');
1173+
throw e;
11751174
}
11761175
};
11771176
return HttpBackendService;
@@ -1262,15 +1261,12 @@ var HttpClientBackendService = (function (_super) {
12621261
return resOptions$.map(function (opts) { return new _angular_common_http.HttpResponse(opts); });
12631262
};
12641263
HttpClientBackendService.prototype.setPassThruBackend = function () {
1265-
this.passThruBackend = undefined;
1266-
if (this.config.passThruUnknownUrl) {
1267-
try {
1268-
this.passThruBackend = new _angular_common_http.HttpXhrBackend(this.xhrFactory);
1269-
}
1270-
catch (ex) {
1271-
ex.message = 'Cannot create passThru404 backend; ' + (ex.message || '');
1272-
throw ex;
1273-
}
1264+
try {
1265+
this.passThruBackend = new _angular_common_http.HttpXhrBackend(this.xhrFactory);
1266+
}
1267+
catch (ex) {
1268+
ex.message = 'Cannot create passThru404 backend; ' + (ex.message || '');
1269+
throw ex;
12741270
}
12751271
};
12761272
return HttpClientBackendService;

http-backend.service.js

+13-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)