open-uri for xyzzy Lisp.
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
reference
site-lisp
.gitattributes
.gitignore
COPYING
ChangeLog
History.md
MANIFEST.yml
README.md

README.md

xl-open-uri - open-uri for xyzzy Lisp.

SYNOPSIS

user> (require "open-uri")
t

user> (open-uri:with-open-uri (f "http://www.ruby-lang.org/")
        (format t "~A" (open-uri:read-all f)))
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
...
nil

;; メタ情報の取得
user> (open-uri:with-open-uri (f "http://www.ruby-lang.org/"
                                 :headers '(:Accept-Language "ja, en"))
        (values (multiple-value-list (open-uri:status f))
                (open-uri:meta f)
                (open-uri:meta f :content-length)
                (open-uri:base-uri f)
                (open-uri:content-type f)
                (open-uri:charset f)))
(200 "OK") ;
(("Connection" . "Keep-Alive") ("Date" . "Thu, 09 Feb 2012 12:42:18 GMT") ...) ;
nil ;
"http://www.ruby-lang.org/ja/" ;
"text/html" ;
"utf-8"

;; open と with-open-file を URI 対応にする
user> (open-uri.ext:install)
nil

;; Content-Encoding の取得 (gzip の展開は自動的には行われません)
user> (with-open-file (f "http://www.yahoo.co.jp/"
                         :headers '(:Accept-Encoding "gzip, deflate"))
        (open-uri:content-encoding f))
("gzip")

;; HEAD リクエストの送信
user> (with-open-file (f "http://www.jsdlab.co.jp/~kamei/cgi-bin/download.cgi"
                         :method "HEAD")
        (decode-universal-time
         (open-uri:last-modified f)))
21 ;
28 ;
1 ;
8 ;
12 ;
2005 ;
3 ;
nil ;
-9

;; FTP (ダウンロード)
user> (open-uri:with-open-uri (f "ftp://ftp.gnu.org/gnu/clisp/clisp.png")
        (values
         (open-uri:read-block f 4)
         (format-date-string "%Y/%m/%d %H:%M:%S"
                             (open-uri:last-modified f))))
"\x89PNG" ;
"2001/12/18 05:59:49"

;; FTP (アップロード)
user> (open-uri:with-open-uri (os "ftp://example.com/public_html/hello.txt"
                                  :direction :output
                                  :if-exists :overwrite
                                  :encoding :binary
                                  :auth '("user" "pass"))
        (with-open-file (is "hello.txt" :encoding :binary)
          (alexandria:copy-stream is os)))
13730

;; data URL の読み込み
user> (open-uri:with-open-uri (s "data:text/plain;charset=utf-8,xyzzy%20%E8%AA%AD%E3%81%BF%E6%96%B9")
        (values (open-uri:base-uri s)
                (open-uri:content-type s)
                (open-uri:charset s)
                (open-uri:read-all s)))
"data:text/plain; charset=utf-8,xyzzy%20%E8%AA%AD%E3%81%BF%E6%96%B9" ;
"text/plain" ;
"utf-8" ;
"xyzzy 読み方"

DESCRIPTION

xl-open-uri は Ruby の open-uri とほぼ同様の機能を xyzzy Lisp に実装したライブラリです。 HTTP や FTP に簡単にアクセスするための機能を提供します。

デフォルトでサポートしている URL スキームは http, https, ftp, data です。 また、URL スキームを追加するための API も公開しています。

Ruby の open-uri では HTTP GET および FTP のダウンロードしか対応していませんが、 xl-open-uri では任意の HTTP メソッドの送信が可能です。 また FTP のアップロードにも対応しています。

INSTALL

  1. NetInstaller で xl-open-uri, http-client, xl-winhttp, xl-alexandria, ansi-loop, ansify, setf-values をインストールします。

  2. xl-open-uri はライブラリであるため自動的にロードはされません。 必要な時点で require してください。

REFERENCE

  • references/ 配下を見てください。

TODO

なし。

KNOWN BUGS

なし。

要望やバグは GitHub Issues@miyamuko まで。

AUTHOR

みやむこ かつゆき (mailto:miyamuko@gmail.com)

COPYRIGHT

xl-open-uri は MIT/X ライセンスに従って本ソフトウェアを使用、再頒布することができます。

Copyright (c) 2012 MIYAMUKO Katsuyuki.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.