0
這裏的後端代碼:奇怪的尾隨字符
res.statusCode = 400
res.setHeader 'Content-Type', 'text/plain'
res.end 'Invalid API endpoint.'
當我從終端捲曲它,我得到:
Invalid API endpoint.%
的「%」符號顯示了反色。
爲什麼那個「%」在那裏籤?
這裏的後端代碼:奇怪的尾隨字符
res.statusCode = 400
res.setHeader 'Content-Type', 'text/plain'
res.end 'Invalid API endpoint.'
當我從終端捲曲它,我得到:
Invalid API endpoint.%
的「%」符號顯示了反色。
爲什麼那個「%」在那裏籤?
這標誌着部分行,因爲響應發送沒有尾隨換行符。從
man zshoptions
PROMPT_SP <D> Attempt to preserve a partial line (i.e. a line that did not end with a newline) that would otherwise be covered up by the command prompt due to the PROMPT_CR option. This works by out‐ putting some cursor-control characters, including a series of spaces, that should make the terminal wrap to the next line when a partial line is present (note that this is only success‐ ful if your terminal has automatic margins, which is typical).
When a partial line is preserved, by default you will see an
inverse+bold character at the end of the partial line: a "%"
for a normal user or a "#" for root. If set, the shell parame‐
ter PROMPT_EOL_MARK can be used to customize how the end of
partial lines are shown.
NOTE: if the PROMPT_CR option is not set, enabling this option
will have no effect. This option is on by default.
謝謝!順便說一下,應該在文本/平原響應中附加一個尾隨的換行符? – Max
完全取決於它將如何使用。 –
現在我只想發送一個簡單的純文本消息供人閱讀,比如「無效的API端點」。 – Max