Skip to content

Commit 973de3b

Browse files
remove botid header (#296)
1 parent 55f1e5e commit 973de3b

2 files changed

Lines changed: 5 additions & 58 deletions

File tree

src/directLine.test.ts

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -241,48 +241,4 @@ describe('MockSuite', () => {
241241
expect(actualError.status).toStrictEqual(429);
242242
expect(endTime - startTime).toStrictEqual(10);
243243
});
244-
245-
test('SendDebugHeader', () => {
246-
let expectedBotId:string;
247-
const actual = 'botid';
248-
services.ajax = DirectLineMock.mockAjax(server, (urlOrRequest) => {
249-
if(typeof urlOrRequest === 'string'){
250-
throw new Error();
251-
}
252-
253-
if(urlOrRequest.url && urlOrRequest.url.indexOf(server.conversation.conversationId)>0){
254-
const response: Partial<AjaxResponse> = {
255-
response: {id:'blah'},
256-
status: 200
257-
};
258-
expectedBotId = urlOrRequest.headers['x-ms-bot-id'];
259-
return response as AjaxResponse;
260-
}
261-
else if(urlOrRequest.url && urlOrRequest.url.indexOf('/conversations') > 0){
262-
// start conversation
263-
const response: Partial<AjaxResponse> = {
264-
response: server.conversation,
265-
status: 201,
266-
xhr: {
267-
getResponseHeader: (name) => actual
268-
} as XMLHttpRequest
269-
};
270-
return response as AjaxResponse;
271-
}
272-
throw new Error();
273-
});
274-
directline = new DirectLineExport.DirectLine(services);
275-
const scenario = function* (): IterableIterator<Observable<unknown>> {
276-
yield Observable.timer(200, scheduler);
277-
yield directline.postActivity(expected.x).catch(() => Observable.empty(scheduler));
278-
};
279-
280-
// lack of subscribe arguments means that the empty subscriber is used
281-
// the empty subscriber will propagate observable errors on the JS call stack
282-
// within the scheduler notification action handling loop because of the observeOn
283-
subscriptions.push(lazyConcat(scenario()).observeOn(scheduler).subscribe());
284-
scheduler.flush();
285-
286-
expect(expectedBotId).toBe(actual);
287-
});
288244
});

src/directLine.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,6 @@ export class DirectLine implements IBotConnection {
466466
private services: Services;
467467
private _userAgent: string;
468468
public referenceGrammarId: string;
469-
private botIdHeader: string;
470469
private timeout = 20 * 1000;
471470
private retries: number;
472471

@@ -627,15 +626,7 @@ export class DirectLine implements IBotConnection {
627626
}
628627
})
629628
// .do(ajaxResponse => konsole.log("conversation ajaxResponse", ajaxResponse.response))
630-
.map(ajaxResponse => {
631-
try{
632-
if(!this.botIdHeader ){
633-
this.botIdHeader = ajaxResponse.xhr.getResponseHeader('x-ms-bot-id');
634-
}
635-
}
636-
catch{/*don't care if the above throws for any reason*/}
637-
return ajaxResponse.response as Conversation;
638-
})
629+
.map(ajaxResponse => ajaxResponse.response as Conversation)
639630
.retryWhen(error$ =>
640631
// for now we deem 4xx and 5xx errors as unrecoverable
641632
// for everything else (timeouts), retry for a while
@@ -992,10 +983,10 @@ export class DirectLine implements IBotConnection {
992983
}
993984

994985
private commonHeaders() {
995-
return Object.assign({
996-
"Authorization": `Bearer ${this.token}`,
997-
"x-ms-bot-agent": this._botAgent
998-
}, this.botIdHeader ? {'x-ms-bot-id': this.botIdHeader}: null);
986+
return {
987+
"Authorization": `Bearer ${this.token}`,
988+
"x-ms-bot-agent": this._botAgent
989+
};
999990
}
1000991

1001992
private getBotAgent(customAgent: string = ''): string {

0 commit comments

Comments
 (0)