Skip to content

fix: keep the whole reason phrase in stat errors - #418

Open
jmrplens wants to merge 1 commit into
perry-mitchell:masterfrom
jmrplens:fix/propstat-status-text
Open

jmrplens wants to merge 1 commit into
perry-mitchell:masterfrom
jmrplens:fix/propstat-status-text

Conversation

@jmrplens

Copy link
Copy Markdown

Fixes #417.

parseStat split the propstat status line into three fields, so any reason phrase longer than one word lost its tail in the error message: HTTP/1.1 404 Not Found became Invalid response: 404 Not, and the HTTP/1.1 425 TOO EARLY that OpenCloud and oCIS return for a file still in post-processing became Invalid response: 425 TOO, which is the string users of clients built on this library have been reporting (remotely-save/remotely-save#1164, opencloud-eu/opencloud#3475).

The change splits on every space and joins the remainder back as the reason phrase, and trims the message when a server sends no reason phrase at all (that case used to read 404 undefined). err.status is unchanged.

Tests: one on the existing nginx-not-found fixture asserting the full Invalid response: 404 Not Found, and one on a new propfind-too-early fixture shaped like the OpenCloud/oCIS response, asserting status === 425 and Invalid response: 425 TOO EARLY. Both fail on master with exactly the truncated strings and pass with the change. npm run test:node (134 tests), test:types (4), test:web (27) and test:format pass locally.

parseStat split the propstat status line into three fields, so any
reason phrase longer than one word lost its tail in the error message:
"HTTP/1.1 404 Not Found" became "Invalid response: 404 Not", and the
"HTTP/1.1 425 TOO EARLY" that OpenCloud and oCIS return for a file that
is still in post-processing became "Invalid response: 425 TOO", which is
how it reached users of clients built on this library.

Split on every space and join the rest back, and trim the message when
a server sends no reason phrase at all.
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.

parseStat truncates multi-word reason phrases in error messages ("404 Not", "425 TOO")

1 participant