You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-08-05 00:42:10 +03:00
Fall back to the unstable endpoint if we receive a 405 status
This commit is contained in:
@@ -417,7 +417,7 @@ describe("MatrixClient", function () {
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should fallback to unstable endpoint when no support for stable endpoint", async () => {
|
it("should fallback to unstable endpoint when stable endpoint 404s", async () => {
|
||||||
await assertRequestsMade([
|
await assertRequestsMade([
|
||||||
{
|
{
|
||||||
prefix: ClientPrefix.V1,
|
prefix: ClientPrefix.V1,
|
||||||
@@ -433,6 +433,22 @@ describe("MatrixClient", function () {
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should fallback to unstable endpoint when stable endpoint 405s", async () => {
|
||||||
|
await assertRequestsMade([
|
||||||
|
{
|
||||||
|
prefix: ClientPrefix.V1,
|
||||||
|
error: {
|
||||||
|
httpStatus: 405,
|
||||||
|
errcode: "M_UNRECOGNIZED",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prefix: unstableMSC3030Prefix,
|
||||||
|
data: { event_id: eventId },
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
it("should not fallback to unstable endpoint when stable endpoint returns an error", async () => {
|
it("should not fallback to unstable endpoint when stable endpoint returns an error", async () => {
|
||||||
await assertRequestsMade(
|
await assertRequestsMade(
|
||||||
[
|
[
|
||||||
|
@@ -9391,7 +9391,10 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|||||||
((<MatrixError>err).httpStatus === 400 ||
|
((<MatrixError>err).httpStatus === 400 ||
|
||||||
// This the correct standard status code for an unsupported
|
// This the correct standard status code for an unsupported
|
||||||
// endpoint according to MSC3743.
|
// endpoint according to MSC3743.
|
||||||
(<MatrixError>err).httpStatus === 404)
|
(<MatrixError>err).httpStatus === 404 ||
|
||||||
|
// This the correct standard status code for an invalid
|
||||||
|
// method according to MSC3743.
|
||||||
|
(<MatrixError>err).httpStatus === 405)
|
||||||
) {
|
) {
|
||||||
return await this.http.authedRequest(Method.Get, path, queryParams, undefined, {
|
return await this.http.authedRequest(Method.Get, path, queryParams, undefined, {
|
||||||
prefix: "/_matrix/client/unstable/org.matrix.msc3030",
|
prefix: "/_matrix/client/unstable/org.matrix.msc3030",
|
||||||
|
Reference in New Issue
Block a user