fix duplicate authorization header 97/92597/4
authorTaka Cho <takamune.cho@att.com>
Fri, 2 Aug 2019 17:39:15 +0000 (13:39 -0400)
committerPatrick Brady <patrick.brady@att.com>
Mon, 5 Aug 2019 18:30:19 +0000 (18:30 +0000)
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>
src/app/shared/services/httpUtil/http-util.service.ts

index 688f3ea..fc9c327 100644 (file)
@@ -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
+}