mirror of
https://gitlab.com/eql/lqml.git
synced 2026-01-06 01:02:10 -08:00
add QML auto reload for mobile (example 'swank-server' only); several revisions
This commit is contained in:
parent
79a5e5cc30
commit
24c2a57fa0
25 changed files with 213 additions and 86 deletions
28
examples/swank-server/lisp/curl.lisp
Normal file
28
examples/swank-server/lisp/curl.lisp
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
(in-package :qml)
|
||||
|
||||
(defun curl (url)
|
||||
"args: (url)
|
||||
Trivial download of UTF-8 encoded files, or binary files."
|
||||
(multiple-value-bind (response headers stream)
|
||||
(loop
|
||||
(multiple-value-bind (response headers stream)
|
||||
(ecl-curl::url-connection url)
|
||||
(unless (member response '(301 302))
|
||||
(return (values response headers stream)))
|
||||
(close stream)
|
||||
(setf url (header-value :location headers))))
|
||||
(if (>= response 400)
|
||||
(qlog "curl download error:" :url url :response response)
|
||||
(let ((byte-array (make-array 0 :adjustable t :fill-pointer t
|
||||
:element-type '(unsigned-byte 8)))
|
||||
(type (pathname-type url)))
|
||||
(x:while-it (read-byte stream nil nil)
|
||||
(vector-push-extend x:it byte-array))
|
||||
(close stream)
|
||||
(if (or (search type "txt html lisp")
|
||||
(search "/cgi-bin/" (namestring url)))
|
||||
(qfrom-utf8 byte-array)
|
||||
byte-array)))))
|
||||
|
||||
(export 'curl)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue