Skip to content

XHTTP: only force trailing path slash when session/seq use path placement#6307

Open
dudkin-2005 wants to merge 1 commit into
XTLS:mainfrom
dudkin-2005:xhttp-conditional-trailing-slash
Open

XHTTP: only force trailing path slash when session/seq use path placement#6307
dudkin-2005 wants to merge 1 commit into
XTLS:mainfrom
dudkin-2005:xhttp-conditional-trailing-slash

Conversation

@dudkin-2005

@dudkin-2005 dudkin-2005 commented Jun 10, 2026

Copy link
Copy Markdown

GetNormalizedPath always appends a trailing slash to the configured path.
That slash is only meaningful when sessionID and/or seq are carried in the
path: it separates the configured base path from the appended segments and
lets the server slice them back off via req.URL.Path[len(path):].

When both sessionID and seq are placed in query/cookie/header, the path
carries no appended segments, so the forced trailing slash is unnecessary.
It also makes URLs look unnatural — a directory-style trailing slash right
before the query string, or a file path that gets a slash appended after its
extension.

This change makes the trailing slash conditional on path placement being
used for sessionID or seq. The default placement is path, so any config
that does not move both fields off the path keeps the exact previous
behaviour; only configs that move both fields off the path are affected.

Examples

Both meta fields in query

"xhttpSettings": {
  "mode": "packet-up",
  "path": "/stream",
  "sessionIDPlacement": "query",
  "seqPlacement": "query"
}

Before:

GET  /stream/?x_session=<id>
POST /stream/?x_seq=0&x_session=<id>

After:

GET  /stream?x_session=<id>
POST /stream?x_seq=0&x_session=<id>

File-like path — "path": "/stream/filename.extension", both in query:
Before → /stream/filename.extension/?x_session=<id>
After → /stream/filename.extension?x_session=<id>

Unchanged: default (path) placement — "path": "/abc":

GET  /abc/<sessionID>
POST /abc/<sessionID>/<seq>

sessionID and seq are in the path, so the trailing slash is still added — identical to the current behaviour.

Unchanged: root path — "path": "/" stays /?... in all cases.

@dudkin-2005 dudkin-2005 force-pushed the xhttp-conditional-trailing-slash branch from 8a45b8e to da21a8f Compare June 10, 2026 17:37
@dudkin-2005 dudkin-2005 reopened this Jun 10, 2026
@artur002

Copy link
Copy Markdown

By the way, you can check the patch and include this code snippet in the branch. You do realize this is an inherent shortcoming, right? Xray has always been highly flexible when it comes to traffic configuration. This looks more like an oversight.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants