XHTTP: only force trailing path slash when session/seq use path placement#6307
XHTTP: only force trailing path slash when session/seq use path placement#6307dudkin-2005 wants to merge 1 commit into
Conversation
8a45b8e to
da21a8f
Compare
|
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. |
|
@RPRX merge |
|
我得评估下新旧版本兼容性问题, |
Yes, I tested this; an xray update on the server is required because it can't validate the path. [Info] transport/internet/splithttp: failed to validate path, request:/stream/filename.extension, config:/stream/filename.extension/ If the client uses a version of xray without this commit, and the server does have this commit, then this will work, because the serveHttp function in hub.go checks whether the path of the incoming HTTP request starts with a certain prefix: |
you've already committed breaking change with sessionTables, it won't change much, people who need backward compatibility can add / at the end of their path, additionally you can create a sub option in config in extra to disable slash behavior for query mode if you really need that, but i dont see any reasons to, query and path are split into two different independent chunks even by nginx |
GetNormalizedPathalways 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 configthat 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
Before:
After:
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":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.