kzfm1024
kzfm1****@gmail*****
2009年 4月 15日 (水) 00:49:19 JST
尾山と申します。 以下のようなレスポンスを返すサイトに対して http-get を 実行したところ ブロックしたまま返ってこなくなりました。 HTTP/1.1 301 MovedPermanently Date: Mon, 13 Apr 2009 13:49:47 GMT Server: Server x-amz-id-1: 1D8FH40X7ZTQPMF8S5DA p3p: policyref="http://www.amazon.com/w3c/p3p.xml",CP="AMZN " x-amz-id-2: 6R7aDSk08UmlmJY1rkw1wLWWks8vpDL7 Location: http://www.amazon.com/gp/dmusic/media/log_action.mp3?ie=UTF8&ASIN=B001AUEMFS&TYPE=DigitalMusicSampleStreamSampler&CustomerID=&URL=http%3A%2F%2Famazonm-666.vo.llnwd.net%2Fs%2Fd7%2F100513%2F100513276%2F206028666%5FS64.mp3%3Fe%3D1239634187%26h%3Dd1337683d6e7094fe05f9e91a963bcef Vary: Accept-Encoding,User-Agent Content-Type: text/html; charset=ISO-8859-1 Set-cookie: session-id-time=1240210800l; path=/; domain=.amazon.com; expires=Mon Apr 20 07:00:00 2009 GMT Set-cookie: session-id=000-0000000-0000000; path=/; domain=.amazon.com; expires=Mon Apr 20 07:00:00 2009 GMT Content-Length: 0 Cneonction: close Connection: Keep-Alive gosh> (sampleTrack "B001AUEMFS") C-c C-c*** UNHANDLED-SIGNAL-ERROR: unhandled signal 2 (SIGINT) Stack Trace: _______________________________________ 0 (read-block! buf src) At line 146 of "/usr/local/share/gauche/0.8.14/lib/gauche/ portutil.scm" 1 (copy-port remote sink) At line 298 of "/usr/local/share/gauche/0.8.14/lib/rfc/ http.scm" 2 (loop109 (cddr args108) G110 G111) [unknown location] 3 (with-error-handler (lambda (e) (let ((e e)) (%guard-rec e e (else ... [unknown location] 4 (request-response request conn host request-uri request-body opts) At line 179 of "/usr/local/share/gauche/0.8.14/lib/rfc/ http.scm" 5 (amazon-mp3-sampleTrack "xxxxxx" asin) At line 94 of "(stdin)" 調べてみたところ Content-Length が 0 の場合は receive- body-nochunked が size 0 で実行されます。そして receive-body-nochunked の中で copy-port が 実行されて read-block! でブロックしています。 とりあえず receive-body-nochunked を以下のように修正し たところ、 リダイレクトされて動作するようになりました。 *** http.scm.org 2009-04-13 23:26:26.000000000 +0900 --- http.scm 2009-04-14 00:19:47.000000000 +0900 *************** *** 298,304 **** (flusher sink headers)) (define (receive-body-nochunked size remote sink) ! (copy-port remote sink :size size)) ;; NB: chunk extension and trailer are ignored for now. (define (receive-body-chunked remote sink) --- 298,304 ---- (flusher sink headers)) (define (receive-body-nochunked size remote sink) ! (when (positive? size) (copy-port remote sink :size size))) ;; NB: chunk extension and trailer are ignored for now. (define (receive-body-chunked remote sink) 以上、よろしくお願いします。