summaryrefslogtreecommitdiff
path: root/http-client.scm
diff options
context:
space:
mode:
authorPeter Bex <peter@more-magic.net>2024-06-28 09:04:48 +0200
committerPeter Bex <peter@more-magic.net>2024-06-28 09:04:48 +0200
commit8f92a6c32da01150400261515d3a4aa8a6ac4470 (patch)
treeed2e095add50cef405a84aff31a079d0dd3a720b /http-client.scm
parent64563b82ae1ddc87900aebad34529516f34657f7 (diff)
downloadhttp-client-8f92a6c32da01150400261515d3a4aa8a6ac4470.tar.gz
Check for closed ports when writing chunks and give a hint to the user1.2.2
This makes it a bit more obvious what happened in cases like #1838, reported by Woodrow E Douglass. While at it, add some more test cases for this particular case, but also for retry-attempts, as this is also affected when retry is allowed for non-idempotent requests (which is pretty uncommon, but possible)
Diffstat (limited to 'http-client.scm')
-rw-r--r--http-client.scm10
1 files changed, 9 insertions, 1 deletions
diff --git a/http-client.scm b/http-client.scm
index 0dd9dff..58d045d 100644
--- a/http-client.scm
+++ b/http-client.scm
@@ -751,8 +751,16 @@
(open-input-file (cdr chunk))
;; Should be a port otherwise
(cdr chunk))))
+ (when (port-closed? p)
+ (raise (http-client-error 'call-with-input-request*
+ (conc "At least one port for the multipart body has been already "
+ "consumed and closed. This may be due to a retry or a redirect. "
+ "Hint: use 'data:' or limit max-retry-attempts and "
+ "max-redirect-depth to zero and catch the resulting exception")
+ (list p)
+ 'port-already-consumed 'port p)))
(handle-exceptions exn
- (begin (close-input-port p) (raise exn))
+ (begin (close-input-port p) (raise exn))
(sendfile p output-port))
(close-input-port p))
(display chunk output-port)))