1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-22 05:22:39 +03:00

Only use the first 3 viaServers specified (#5034)

* Only use the first 3 viaServers specified

To avoid HTTP 414 URI Too Long error

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Iterate

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

---------

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski
2025-10-07 14:14:13 +01:00
committed by GitHub
parent b3d217717a
commit a03cf054a8
2 changed files with 8 additions and 4 deletions

View File

@@ -34,6 +34,7 @@ export interface IJoinRoomOpts {
/** /**
* The server names to try and join through in addition to those that are automatically chosen. * The server names to try and join through in addition to those that are automatically chosen.
* Only the first 3 are actually used in the request, to avoid HTTP 414 Request-URI Too Long responses.
*/ */
viaServers?: string[]; viaServers?: string[];
@@ -71,6 +72,7 @@ export interface KnockRoomOpts {
/** /**
* The server names to try and knock through in addition to those that are automatically chosen. * The server names to try and knock through in addition to those that are automatically chosen.
* Only the first 3 are actually used in the request, to avoid HTTP 414 Request-URI Too Long responses.
*/ */
viaServers?: string | string[]; viaServers?: string | string[];
} }

View File

@@ -2391,8 +2391,8 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
const queryParams: QueryDict = {}; const queryParams: QueryDict = {};
if (opts.viaServers) { if (opts.viaServers) {
// server_name has been deprecated in favour of via with Matrix >1.11 (MSC4156) // server_name has been deprecated in favour of via with Matrix >1.11 (MSC4156)
queryParams.server_name = opts.viaServers; // We only use the first 3 servers, to avoid URI length issues.
queryParams.via = opts.viaServers; queryParams.via = queryParams.server_name = opts.viaServers.slice(0, 3);
} }
const data: IJoinRequestBody = {}; const data: IJoinRequestBody = {};
@@ -2436,9 +2436,11 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
const queryParams: QueryDict = {}; const queryParams: QueryDict = {};
if (opts.viaServers) { if (opts.viaServers) {
// We only use the first 3 servers, to avoid URI length issues.
const viaServers = Array.isArray(opts.viaServers) ? opts.viaServers.slice(0, 3) : [opts.viaServers];
// server_name has been deprecated in favour of via with Matrix >1.11 (MSC4156) // server_name has been deprecated in favour of via with Matrix >1.11 (MSC4156)
queryParams.server_name = opts.viaServers; queryParams.server_name = viaServers;
queryParams.via = opts.viaServers; queryParams.via = viaServers;
} }
const body: Record<string, string> = {}; const body: Record<string, string> = {};