diff options
author | Taka Cho <takamune.cho@att.com> | 2019-08-02 13:39:15 -0400 |
---|---|---|
committer | Patrick Brady <patrick.brady@att.com> | 2019-08-05 18:30:19 +0000 |
commit | 77e0562f5040f2621ecc6574c01e6cc601d7d6c3 (patch) | |
tree | 24d83c7ab555b3f20affd332b71fe4b6eda2874b /src/app/shared | |
parent | cbae8033683053ccbd25e9a2a737158bfc3ec448 (diff) |
fix duplicate authorization header
Authorization
Basic YWRtaW46YWRtaW4=
will not be duplicated and cached
Issue-ID: APPC-1676
Change-Id: I9858e72c1b0158791d11c301d9c118a422b3e0b6
Signed-off-by: Taka Cho <takamune.cho@att.com>
Diffstat (limited to 'src/app/shared')
-rw-r--r-- | src/app/shared/services/httpUtil/http-util.service.ts | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/app/shared/services/httpUtil/http-util.service.ts b/src/app/shared/services/httpUtil/http-util.service.ts index 688f3ea..fc9c327 100644 --- a/src/app/shared/services/httpUtil/http-util.service.ts +++ b/src/app/shared/services/httpUtil/http-util.service.ts @@ -26,23 +26,28 @@ import { Http, Response, Headers, RequestOptions } from '@angular/http'; @Injectable() export class HttpUtilService { - headers: Headers; + headersGET: Headers; + headersPOST: Headers; options: RequestOptions private username = require('../../../../cdt.application.properties.json').username; private password = require('../../../../cdt.application.properties.json').password; constructor(private http: Http) { - this.headers = new Headers({ 'Content-Type': 'application/json' }); // ... Set content type to JSON + this.headersGET = new Headers({ 'Content-Type': 'application/json' }); // ... Set content type to JSON + this.headersPOST = new Headers({ 'Content-Type': 'application/json' }); // ... Set content type to JSON + this.headersPOST.append('Authorization', 'Basic ' + btoa(this.username + ':' + this.password)); } get(req) { + this.options = new RequestOptions({ headers: this.headersGET }); + return this .http .get(req.url, this.options) .map((res: Response) => res.json()) } post(req) { - this.headers.append('Authorization', 'Basic ' + btoa(this.username + ':' + this.password)); - this.options = new RequestOptions({ headers: this.headers }); + + this.options = new RequestOptions({ headers: this.headersPOST }); return this .http @@ -50,4 +55,4 @@ export class HttpUtilService { .map((res: Response) => res.json()) } -}
\ No newline at end of file +} |