Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix gxhttpd bug: No content length when chunking #1292

Merged
merged 2 commits into from
Jan 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/tools/gxhttpd.ss
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@
(mux (make-mux cfg))
(request-logger (get-request-logger cfg))
(addresses (config-get! cfg listen:))
(max-token-length (: (config-get cfg max-token-length: 1024) :fixnum))
(max-token-length (: (config-get cfg max-token-length: 1024) :fixnum))
(run-httpd
(lambda ()
(set-httpd-max-token-length! max-token-length)
Expand Down Expand Up @@ -478,11 +478,11 @@
=> :procedure
(let* ((content-type (path-extension->mime-type-name path))
(headers
[(if content-type
[["Content-Length" :: (number->string (file-info-size info))]
(if content-type
["Content-Type" :: content-type]
["Content-Type" :: "application/octet-stream"])
["Last-Modified" :: (number->string (exact (floor (time->seconds (file-info-last-modification-time info)))))]
["Content-Length" :: (number->string (file-info-size info))]]))
["Last-Modified" :: (number->string (exact (floor (time->seconds (file-info-last-modification-time info)))))]]))

(if (fx<= (file-info-size info) max-file-cache-size)
;; cache the content
Expand All @@ -501,12 +501,16 @@
(using (req :- http-request)
(case req.method
((GET)
(http-response-file res headers path))
;; RFC 9112 states that "a sender (server) MUST NOT send
;; a Content-Length header field in any message that
;; contains a Transfer-Encoding header field.".
(http-response-file res (cdr headers) path))
drewc marked this conversation as resolved.
Show resolved Hide resolved
((HEAD)
(http-response-write res 200 headers #f))
(else
(http-response-write-condition res Forbidden))))))))


(def (find-handler tab server-path)
(let loop ((path server-path))
(cond
Expand Down
Loading