Skip to content

Commit f30395b

Browse files
committed
resolved #21 check response body type properly
1 parent d044fc9 commit f30395b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/abpHttpInterceptor.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export class AbpHttpConfiguration {
139139

140140
handleAbpResponse(response: HttpResponse<any>, ajaxResponse: IAjaxResponse): HttpResponse<any> {
141141
var newResponse: HttpResponse<any>;
142-
142+
143143
if (ajaxResponse.success) {
144144

145145
newResponse = response.clone({
@@ -236,7 +236,7 @@ export class AbpHttpInterceptor implements HttpInterceptor {
236236

237237
var interceptObservable = new Subject<HttpEvent<any>>();
238238
var modifiedRequest = this.normalizeRequestHeaders(request);
239-
239+
240240
next.handle(modifiedRequest)
241241
.catch((error: any, caught: Observable<any>) => {
242242
return this.handleErrorResponse(error, interceptObservable);
@@ -318,13 +318,14 @@ export class AbpHttpInterceptor implements HttpInterceptor {
318318

319319
protected handleSuccessResponse(event: HttpEvent<any>, interceptObservable: Subject<HttpEvent<any>>): void{
320320
var self = this;
321-
if (event instanceof HttpResponse) {
322321

323-
if (event.body instanceof Blob && event.body.type === "application/json"){
322+
if (event instanceof HttpResponse) {
323+
if (event.body instanceof Blob && event.body.type && event.body.type.indexOf("application/json") >= 0){
324324
var clonedResponse = event.clone();
325325

326326
self.configuration.blobToText(event.body).subscribe(json => {
327327
const responseBody = json == "null" ? {}: JSON.parse(json);
328+
328329
var modifiedResponse = self.configuration.handleResponse(event.clone({
329330
body: responseBody
330331
}));

0 commit comments

Comments
 (0)