Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#436: Mapped remote response headers #437

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/runtime/src/models/Request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ export default class Request

setHeader(name: string, value: string): void
{
this.#headers.set(name, value);
this.#headers.set(name.toLowerCase(), value);
}

getHeader(name: string): string | undefined
{
return this.#headers.get(name);
return this.#headers.get(name.toLowerCase());
}

removeHeader(name: string): void
{
this.#headers.delete(name);
this.#headers.delete(name.toLowerCase());
}
}
6 changes: 3 additions & 3 deletions packages/runtime/src/models/Response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ export default class Response

setHeader(name: string, value: string): void
{
this.#headers.set(name, value);
this.#headers.set(name.toLowerCase(), value);
}

getHeader(name: string): string | undefined
{
return this.#headers.get(name);
return this.#headers.get(name.toLowerCase());
}

removeHeader(name: string): void
{
this.#headers.delete(name);
this.#headers.delete(name.toLowerCase());
}
}
15 changes: 14 additions & 1 deletion packages/runtime/src/services/Remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ export default class Remote

const response = await this.#callRemote(url, options, 200);
const result = await this.#createResponseResult(response);
const headers = this.#createResponseHeaders(response);

return new ResultResponse(result);
return new ResultResponse(result, headers);
}

async #callRemote(url: string, options: object, expectedStatus: number): Promise<Response>
Expand Down Expand Up @@ -151,4 +152,16 @@ export default class Remote

return response.text();
}

#createResponseHeaders(response: Response): Map<string, string>
{
const headers = new Map();

for (const [name, value] of response.headers)
{
headers.set(name, value);
}

return headers;
}
}