Last active
May 28, 2020 23:48
-
-
Save aw/7b0159ae4f4eb1e2f65e946876d133b1 to your computer and use it in GitHub Desktop.
[PicoLisp] Store extra HTTP headers in global variable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# load this code after loading http.l | |
# ex: pil http.l headers-patch.l --server 8000 yourcode.l | |
(patch _htHead | |
'(T (if (eol) (char) (line T) @S)) | |
(fill '(T (if (eol) (char) (when @ (push '*Headers (list @ (cdr (line)))))) | |
. @S) ) ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# v1 | |
diff --git a/lib/http.l b/lib/http.l | |
index f274334..4046537 100644 | |
--- a/lib/http.l | |
+++ b/lib/http.l | |
@@ -267,7 +267,7 @@ | |
(when (till "=^M^J") | |
(_htSet @ (ht:Pack (cdr (line)) T)) | |
T ) ) | |
- (T (if (eol) (char) (line T))) ) ) | |
+ (T (if (eol) (char) (when @ (push '*Headers (list @ (cdr (line))))))) ) ) | |
(unless *Gate | |
(and (member ":" *Host) (con (prior @ *Host))) ) ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This minor code change makes HTTP headers accessible through the global variable
*Headers
. It does not include the headers already processed by PicoLisp such ashost
,referer
,cookie
, etc.Apply the
http.patch
file to make changes permanent, or load the includedheaders-patch.l
after loadinghttp.l
.