1
0
Fork 0

- [gemini] starting download thread in ':rendering' status.

This commit is contained in:
cage 2020-08-29 11:13:29 +02:00
parent 4941c21d94
commit 1c3a3d9bff
1 changed files with 31 additions and 19 deletions

View File

@ -242,7 +242,7 @@
(%fill-buffer)))))) (%fill-buffer))))))
(%fill-buffer)))))) (%fill-buffer))))))
(defun request (url) (defun request (url &key (enqueue nil))
(let ((parsed-uri (quri:uri url))) (let ((parsed-uri (quri:uri url)))
(maybe-initialize-metadata specials:*message-window*) (maybe-initialize-metadata specials:*message-window*)
(if (null parsed-uri) (if (null parsed-uri)
@ -255,20 +255,30 @@
(port (or (quri:uri-port parsed-uri) (port (or (quri:uri-port parsed-uri)
gemini-client:+gemini-default-port+))) gemini-client:+gemini-default-port+)))
(handler-case (handler-case
(flet ((get-user-input (hide-input host prompt) (labels ((gemini-file-stream-p (meta)
(flet ((on-input-complete (input) (gemini-client:mime-gemini-p meta))
(when (string-not-empty-p input) (starting-status (meta)
(db-utils:with-ready-database (:connect nil) (if (gemini-file-stream-p meta)
(request (gemini-parser:make-gemini-uri host (if enqueue
path nil
input :rendering)
port)))))) (if enqueue
(ui:ask-string-input #'on-input-complete nil
:hide-input hide-input nil)))
:prompt (format nil (get-user-input (hide-input host prompt)
(_ "Server ~s asks: ~s ") (flet ((on-input-complete (input)
host (when (string-not-empty-p input)
prompt))))) (db-utils:with-ready-database (:connect nil)
(request (gemini-parser:make-gemini-uri host
path
input
port))))))
(ui:ask-string-input #'on-input-complete
:hide-input hide-input
:prompt (format nil
(_ "Server ~s asks: ~s ")
host
prompt)))))
(multiple-value-bind (status code-description meta response socket) (multiple-value-bind (status code-description meta response socket)
(gemini-client:request host (gemini-client:request host
path path
@ -296,10 +306,12 @@
((gemini-client:response-sensitive-input-p status) ((gemini-client:response-sensitive-input-p status)
(get-user-input t host meta)) (get-user-input t host meta))
((streamp response) ((streamp response)
(if (gemini-client:mime-gemini-p meta) (if (gemini-file-stream-p meta)
(let* ((gemini-stream (make-instance 'gemini-file-stream (let* ((starting-status (starting-status meta))
:download-stream response (gemini-stream (make-instance 'gemini-file-stream
:download-socket socket)) :stream-status starting-status
:download-stream response
:download-socket socket))
(thread-fn (thread-fn
(request-stream-gemini-document-thread gemini-stream (request-stream-gemini-document-thread gemini-stream
host host