5 (rl3 aws awscredentials)
6 (rl3 concurrency tasks-with-io))
8 (define creds (load-credentials "/home/ray/awsaccount.txt"))
12 (display (pretty-print (keyword-search creds "sml%20language")))))
16 (display (pretty-print (item-lookup creds "B000V78UWM")))))
18 ;;==================================================================
25 (rl3 aws awscredentials)
26 (rl3 concurrency tasks-with-io))
28 (define creds (load-credentials "/home/ray/awsaccount.txt"))
32 (display (pretty-print (list-buckets creds)))))
43 (rl3 aws awscredentials)
44 (rl3 aws configuration)
45 (rl3 crypto hash sha1)
46 (only (rl3 aws s3 s3headers)
47 date-header host-header)
60 ;;(rnrs mutable-strings)
61 (rl3 concurrency tasks-with-io)
66 (rl3 web pipes htmlprag)
69 (define creds (load-credentials "/home/ray/awsaccount.txt"))
71 (define base-uri (make-uri "http" #f (s3-configuration 'host) #f "" "" ""))
73 (define build-rest-uri
75 (make-uri "http" #f (s3-configuration 'host) #f path "" "")))
77 (define bucket-root-uri (build-rest-uri ""))
79 (define tstamp (current-time-rfc2822))
81 (define dheader (date-header tstamp))
84 (lambda (creds auth-str)
85 (string-append "Authorization: AWS " (aws-credentials-access-key credentials)
86 ":" (aws-s3-auth-mac (aws-credentials-secret-key credentials) auth-str))))
88 (define auth-str (aws-s3-auth-str "GET" "" "" tstamp '() "/"))
90 (define authorization-header
91 (lambda (credentials auth-str)
92 (string-append "Authorization: AWS " (aws-credentials-access-key credentials)
93 ":" (aws-s3-auth-mac (aws-credentials-secret-key credentials) auth-str))))
95 (define list-headers (list (host-header (s3-configuration 'host))
96 dheader (authorization-header creds auth-str)))
100 (let-values (((hdrs hip) (http-invoke 'GET
101 (uri->string bucket-root-uri)
105 (let ((tip (http-ascii-port-from-binary-port hip)))
106 (display (html->sxml tip))
121 ;;(rnrs mutable-strings)
122 (rl3 concurrency tasks-with-io)
127 (rl3 web pipes htmlprag)
134 (let ((surl "GET /home/will/Larceny/ HTTP/1.1\r\nHost: www.ccs.neu.edu\r\nUser-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.5) Gecko/20070718 Fedora/2.0.0.5-1.fc7 Firefox/2.0.0.5\r\nAccept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\nAccept-Language: en-us,en;q=0.5\r\Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n\r\n")
135 (s (client-socket "www.ccs.neu.edu" 80)))
136 (let ((op (socket-output-port s))
137 (ip (socket-input-port s)))
138 (put-bytevector op (string->utf8 surl))
139 (flush-output-port op)
140 (let ((req (http-request ip)))
141 (let ((hip (http-req-input-port req)))
142 (let ((tip (http-ascii-port-from-binary-port hip)))
143 (format #t "Header: ~a Len: ~a~%" (http-req-start-line req) (http-req-size req))
144 (display (html->sxml tip))))))))))
146 ;; (let loop ((ch (get-char tip)) (cnt 0))
147 ;; (if (eof-object? ch)
149 ;; (display "Total Response Bytes: ")
155 ;; (loop (get-char tip) (+ cnt 1))))))))))))
157 ;; (require 'tasking-with-io)
159 ;; (define (do-n thunk n)
164 ;; (loop (sub1 n))))))
179 ;; (with-tasking (lambda ()
180 ;; (let ((t1 (spawn (lambda () (do-n hi 100))))
181 ;; (t2 (spawn (lambda () (do-n hello 100)))))
182 ;; (let loop ((ts (all-tasks)))
183 ;; (if (> (length ts) 1)
186 ;; (loop (all-tasks)))
199 ;; (require 'Experimental/webserver/web-server.sch)
204 (export EPOLLIN);; EPOLLIN EPOLLOUT)
209 (ffi foreign-ctools))
211 (c-info (include<> "sys/epoll.h")
213 (const EPOLLIN int "EPOLLIN")
214 (const EPOLLPRI int "EPOLLPRI")
215 (const EPOLLOUT int "EPOLLOUT")
216 (const EPOLLRDNORM int "EPOLLRDNORM")
217 (const EPOLLRDBAND int "EPOLLRDBAND")
218 (const EPOLLWRNORM int "EPOLLWRNORM")
219 (const EPOLLWRBAND int "EPOLLWRBAND")
220 (const EPOLLMSG int "EPOLLMSG")
221 (const EPOLLERR int "EPOLLERR")
222 (const EPOLLONESHOT int "EPOLLONESHOT") ;; no more fixnum?
223 (const EPOLLET uint "EPOLLET")
226 (const EPOLL-CTL-ADD int "EPOLL_CTL_ADD")
227 (const EPOLL-CTL-DEL int "EPOLL_CTL_DEL")
228 (const EPOLL-CTL-MOD int "EPOLL_CTL_MOD")
231 (sizeof EPOLL-SIZEOF-STRUCT-EPOLL-EVENT "struct epoll_event")
232 (sizeof EPOLL-SIZEOF-EPOLL-DATA "union epoll_data")
234 (struct "epoll_event"
235 (EPOLL-EVENT-EVENTS "events")
236 (EPOLL-EVENT-DATA "data")))
244 (let ((t1 (make-thread t1 "t1"))
245 (t2 (make-thread t2 "t2")))
260 (display "********DONE**********")
275 (import (rnrs io simple))
276 (import (rnrs io ports))
277 (import (rl3 io net sockets))
278 (import (rl3 io net ipaddress))
279 (import (rl3 concurrency tasks))
280 (import (rl3 concurrency tasks-with-io))
282 (define gurl "GET / HTTP/1.1\r\nHost: www.google.com\r\nUser-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.5) Gecko/20070718 Fedora/2.0.0.5-1.fc7 Firefox/2.0.0.5\r\nAccept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\nAccept-Language: en-us,en;q=0.5\r\Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\nKeep-Alive: 300\r\nConnection: keep-alive\r\n\r\n")
289 (define s (client-socket "www.google.com" 80))
291 (define op (socket-output-port s))
292 (define ip (socket-input-port s))
294 (put-bytevector op (string->utf8 gurl))
295 (flush-output-port op)
297 (let loop ((b (get-bytevector-n ip 1)))
298 (if (or (eof-object? b)
299 (zero? (bytevector-length b)))
302 (display (utf8->string b))
304 (flush-output-port (current-output-port))
305 (loop (get-bytevector-n ip 1)))))))
313 (define s (client-socket "www.google.com" 80))
315 (define op (socket-output-port s #t))
316 (define ip (socket-input-port s #t))
318 (put-bytevector op (string->utf8 gurl))
319 (flush-output-port op)
321 (let loop ((b (get-bytevector-n ip 1)))
322 (if (or (eof-object? b)
323 (zero? (bytevector-length b)))
326 (display (utf8->string b))
328 (flush-output-port (current-output-port))
329 (loop (get-bytevector-n ip 1))))))
334 (socket-descriptor s)
347 (sys system process))
349 (define reduce-r (lambda (pred l)
353 (pred (car l) (reduce-r pred l1))))))
355 (define (call-with-input-pipe command pred)
356 (let* ((results (process (if (string? command)
358 (reduce-r (lambda (arg result)
359 (string-append arg " " result))
361 (result (pred (car results))))
362 (close-input-port (car results))
363 (close-output-port (cadr results))
364 (unix-waitpid (caddr results)) ; important in order to remove process
369 (call-with-input-pipe '("date" "-I")
371 (utf8->string (get-bytevector-n ip 512))))))
374 ;; START HERE - OK must track length of HTTP header. Content-Length + Header = Total to read.
377 (get-bytevector-n! (open-bytevector-input-port (make-bytevector 0))
378 (make-bytevector 32 0)
381 (get-bytevector-n (open-bytevector-input-port (make-bytevector 0)) 16)
388 (haip (http-ascii-port-from-binary-port hip))
389 (html (html->sxml haip)))
394 ;; (if (chunked-encoding? header)
395 ;; (let loop ((chunk (get-chunk ip)))
396 ;; (if (eof-object? chunk)
399 ;; (display "CHUNK -------------")
403 ;; (loop (get-chunk ip)))))))))
407 ;; (time (display (html->sxml ip)))
408 ;; (socket-close s))))
412 (let ((bip (open-bytevector-input-port (string->utf8 "This is how the world ends, not with a bang, but with a whimper."))))
413 (display (get-u8 bip))
414 (let ((tip (html-port bip)))
415 (display (read-char tip))
416 (close-input-port tip)))
419 (define l '#(1 2 3 4 5 6 7 8))
424 (let ((n (vector-ref l idx)))