W7 done done
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
:sig
|
||||
StringMap split_http_headers(String s)
|
||||
|
||||
:params
|
||||
s : HTTP request or header text
|
||||
return value : parsed request/header fields
|
||||
|
||||
:see
|
||||
>string
|
||||
split_kv
|
||||
parse_query
|
||||
0_Request
|
||||
|
||||
:content
|
||||
Parses HTTP request/header text into a `StringMap`.
|
||||
|
||||
For a request line, the returned map includes fields such as `REQUEST_METHOD`, `REQUEST_URI`, `SCRIPT_NAME`, `QUERY_STRING`, and `SERVER_PROTOCOL`. Header names are normalized to uppercase CGI-style keys, for example `Host` becomes `HTTP_HOST`.
|
||||
|
||||
Example:
|
||||
|
||||
```uce
|
||||
StringMap h = split_http_headers("GET /demo.uce?x=1 HTTP/1.1\r\nHost: example.test\r\n\r\n");
|
||||
// h["REQUEST_METHOD"] == "GET"
|
||||
// h["SCRIPT_NAME"] == "/demo.uce"
|
||||
// h["QUERY_STRING"] == "x=1"
|
||||
// h["HTTP_HOST"] == "example.test"
|
||||
```
|
||||
|
||||
Most page code should read `context.params` instead. Use this helper when parsing raw HTTP text in tests or protocol helpers.
|
||||
Reference in New Issue
Block a user