Skip to content

Commit

Permalink
Release 0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
suzdalenator committed May 8, 2010
1 parent ed1a6a6 commit 3d626c1
Show file tree
Hide file tree
Showing 7 changed files with 293 additions and 85 deletions.
10 changes: 10 additions & 0 deletions ChangeLog
@@ -1,3 +1,13 @@
2010-05-08 yuzawat <suzdalenator@gmail.com>

* release 0.2.1
support socket function (--keepalive)
fix %easy-options
* curl.scm
* curllib.stub
* curl.c
* gauche_curl.h

2010-05-05 yuzawat <suzdalenator@gmail.com>

* release 0.2.0
Expand Down
204 changes: 164 additions & 40 deletions README.ja
Expand Up @@ -6,7 +6,7 @@ Abstract:

Author: yuzawat <suzdalenator @ gmail.coml>

Version: 0.2.0 2010/05/05
Version: 0.2.1 2010/05/08
======================================================================

Module: curl
Expand Down Expand Up @@ -48,6 +48,9 @@ Instance Variable of <curl>: options
ただし、コマンドラインパーザの制限で、curlと全て同じ動作にはなっていません。例えばcurl(1)には同じオプションを複数渡すと、値も複数受け取る動作があるのですが、それには従っていません(-H,--headerは、複数指定することでHTTPのヘッダをその数だけ追加できるのですが、それと同じ動作はできません。-H,--headerについては、カンマ(,)で連結した文字列を引数とすることで複数指定に対応しています)。
上記の制限があるので、options での設定がむずかしいものは、curl-setopt!を直接使用して下さい。

Instance Variable of <curl>: no-option
ハンドラーへのデフォルトのオプション設定を無効化します。デフォルトの動作では options の機能で、curl(1)の動作に準じて、暗黙のうちに設定される設定値があります。no-option が #t の場合は、options が行なう設定をすべてスキップします。デフォルトは #f です。

Instance Variable of <curl>: http-headers
HTTPのヘッダーが、文字列のリストで入っています。options経由("--header=hoge:hoge")でも、直接、curl-setopt!での指定(curl-setopt! curl CURLOPT_HTTPHEADER '("hoge:hoge"))を行っても、ここに反映されます。

Expand Down Expand Up @@ -286,14 +289,170 @@ Function: curl-slist->list curl_slist
Schemeの文字列のリストと、<curl-slist>を相互に変換します。

======================================================================
- curl(1)互換の簡易インターフェース(:options)でサポートされているのは以下の通りです
A|user-agent
L|location
location-trusted
X|request
o|output
O|remote-name
R|remote-time
D|dump-header
stderr
v|verbose
ignore-content-length
e|referer
interface
url
tcp-nodelay
compressed
u|user
basic
digest
negotiate
ntlm
anyauth
f|fail
i|include
I|head
G|get
H|header
x|proxy
proxy1.0
socks4
socks4a
socks5
socks5-gssapi-nec
socks5-gssapi-service
socks5-hostname
p|proxytunnel
noproxy
U|proxy-user
proxy-anyauth
proxy-basic
proxy-digest
proxy-negotiate
proxy-ntlm
post301
post302
T|upload-file
j|junk-session-cookies
b|cookie
c|cookie-jar
d|data|data-ascii
data-binary
data-urlencode
max-filesize
max-redirs
connect-timeout
m|max-time
0|http1.0
raw
z|time-cond
r|range
local-port
4|ipv4
6|ipv6
ssl
ssl-reqd
1|tlsv1
2|sslv2
3|sslv3
cacert
capath
cert-type
ciphers
random-file
egd-file
engine
sessionid
no-sessionid
E|cert
key
key-type
pass
k|insecure
pubkey
crlfile
hostpubmd5
P|ftp-port
ftp-pasv
Q|quote
l|list-only
a|append
ftp-create-dirs
B|use-ascii
crlf
disable-eprt
disable-epsv
no-eprt
no-epsv
eprt
epsv
ftp-skip-pasv-ip
ftp-alternative-to-user
ftp-account
ftp-method
krb
ftp-ssl
ftp-ssl-control
ftp-ssl-reqd
ftp-ssl-ccc
ftp-ssl-ccc-mode
t|telnet-option
tftp-blksize
mail-rcpt
mail-from
#|progress-bar
Y|speed-limit
y|speed-time
limit-rate
C|continue-at(引数"-"はサポートせず)
no-keepalive
keepalive
keepalive-time


- 以下のものは同じ文字列での指定ができませんので提示されているように書き換えをお願いします。
--http1.0 => --http1_0
--proxy1.0 => --proxy1_0
-# => なし(--progress-bar で指定してください)


- 以下はサポートされません。
create-dirs
s|silent
q
K|config
n|netrc
netrc-optional
S|show-error
environment
trace
trace-ascii
trace-time
w|write-out
retry
retry-delay
retry-max-time
buffer
N|no-buffer

form-string
g|globoff
remote-name-all

======================================================================

Todo
- 未テストのプロトコルの動作確認
- データアップロード関連の十分なテスト
- test.scmをもう少しましに


制限事項
- curl独自のURLのワイルドカードをサポートしていません(実装するか未定)
- HTTP POST FORMデータ生成の機能が未実装です
- curl独自のURLのワイルドカードをサポートしていません。
- HTTP POST FORMデータ生成の機能をサポートしていません
- 以下のlibcurl関数のバインディングは未実装、もしくは利用しやすいインターフェイスを作っていません。
curl_easy_pause
curl_easy_recv
Expand All @@ -306,45 +465,10 @@ Todo
curl_multi_assign
curl_multi_socket

- curl(1)互換の簡易インターフェース(:options)で、以下のものは同じ文字列での指定ができませんので提示されているように書き換えをお願いします。
--http1.0 => --http1_0
--proxy1.0 => --proxy1_0

- curl(1)互換の簡易インターフェース(:options)で、以下のものが未実装です。
--buffer
-#|--progress-bar
--create-dirs
--environment
--form-string
--keepalive
--limit-rate
--netrc-optional
--no-keepalive
--remote-name-all
--retry
--retry-delay
--retry-max-time
--trace
--trace-ascii
--trace-time
-C|--continue-at
-F|--form
-K|--config
-N|--no-buffer
-S|--show-error
-Y|--speed-limit
-g|--globoff
-n|--netrc
-q
-s|--silent
-w|--write-out
-y|--speed-time
-z|--time-cond
--keepalive-time


動作確認環境(と云っても、"make check"が通るだけ)
- Mac OX X 10.6.3 (libcurl 7.21.1. + Gauche 0.9)
- Mac OX X 10.6.3 (libcurl 7.21.0. + Gauche 0.9)
- Ubuntu 9.04 Jaunty (libcurl 7.21.1. + Gauche 0.9)
- Mac OX X 10.6.2 (libcurl 7.19.7. + Gauche 0.9)
- Mac OX X 10.5.8 (libcurl 7.16.3 + Gauche 0.8.14)
- Mac OX X 10.5.8 (libcurl 7.19.3 + Gauche 0.8.14)
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Expand Up @@ -5,7 +5,7 @@ dnl $Id: template.configure.ac,v 1.3 2005/11/05 00:54:52 shirok Exp $
dnl

AC_PREREQ(2.54)
AC_INIT(Gauche-curl, 0.2.0, shiro@acm.org)
AC_INIT(Gauche-curl, 0.2.1, shiro@acm.org)
dnl If you want to use the system name (OS, architecture, etc) in the
dnl configure, uncomment the following line. In such a case, you need
dnl to copy config.guess and config.sub from automake distribution.
Expand Down
44 changes: 43 additions & 1 deletion curl.c
Expand Up @@ -2,13 +2,20 @@
/*
* curl.c
*
* Last Updated: "2010/05/05 21:11.00"
* Last Updated: "2010/05/08 22:31.55"
*
* Copyright (c) 2010 yuzawat <suzdalenator@gmail.com>
*/

#include "gauche-curl.h"

#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h> /* for IPPROTO_TCP */
#endif
#ifdef HAVE_NETINET_TCP_H
#include <netinet/tcp.h> /* for TCP_KEEPIDLE, TCP_KEEPINTVL */
#endif

/*
* The following function is a dummy one; replace it for
* your C function definitions.
Expand Down Expand Up @@ -681,6 +688,41 @@ int _show_progress (CURLPROGRESS *prog, double dltotal, double dlnow, double ult
return 0;
}

#define SET_SOCKERRNO(x) (errno = (x))

int _set_socket_option(void *clientp, curl_socket_t curlfd, curlsocktype purpose) {
int onoff = 1;
#if defined(TCP_KEEPIDLE) || defined(TCP_KEEPINTVL)
int keepidle = (int)clientp;
#endif

switch (purpose) {
case CURLSOCKTYPE_IPCXN:
if (setsockopt(curlfd, SOL_SOCKET, SO_KEEPALIVE, (void *)&onoff, sizeof(onoff)) < 0) {
SET_SOCKERRNO(0);
return 0;
} else {
if (clientp) {
#ifdef TCP_KEEPIDLE
if (setsockopt(curlfd, IPPROTO_TCP, TCP_KEEPIDLE, (void *)&keepidle, sizeof(keepidle)) < 0) {
SET_SOCKERRNO(0);
return 0;
}
#endif
#ifdef TCP_KEEPINTVL
if (setsockopt(curlfd, IPPROTO_TCP, TCP_KEEPINTVL, (void *)&keepidle, sizeof(keepidle)) < 0) {
SET_SOCKERRNO(0);
return 0;
}
#endif
}
}
break;
default:
break;
}
return 0;
}

/*
* Module initialization function.
Expand Down

0 comments on commit 3d626c1

Please sign in to comment.