-
Notifications
You must be signed in to change notification settings - Fork 58
/
index.html
1807 lines (1568 loc) · 88.7 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>DRAKMA - A Common Lisp web client</title>
<style type="text/css">
pre { padding:5px; background-color:#e0e0e0 }
h3, h4 { text-decoration: underline; }
a { text-decoration: none; padding: 1px 2px 1px 2px; }
a:visited { text-decoration: none; padding: 1px 2px 1px 2px; }
a:hover { text-decoration: none; padding: 1px 1px 1px 1px; border: 1px solid #000000; }
a:focus { text-decoration: none; padding: 1px 2px 1px 2px; border: none; }
a.none { text-decoration: none; padding: 0; }
a.none:visited { text-decoration: none; padding: 0; }
a.none:hover { text-decoration: none; border: none; padding: 0; }
a.none:focus { text-decoration: none; border: none; padding: 0; }
a.noborder { text-decoration: none; padding: 0; }
a.noborder:visited { text-decoration: none; padding: 0; }
a.noborder:hover { text-decoration: none; border: none; padding: 0; }
a.noborder:focus { text-decoration: none; border: none; padding: 0; }
pre.none { padding:5px; background-color:#ffffff }
</style>
</head>
<body bgcolor=white>
<h2>DRAKMA - A Common Lisp web client</h2>
<blockquote>
<br> <br><h3><a name=abstract class=none>Abstract</a></h3>
Drakma is a fully-featured web client (implemented in Common Lisp)
that knows how to handle <a href="#chunked">HTTP/1.1
chunking</a>, <a href="#keep-alive">persistent
connections</a>, <a href="#re-use">re-usable
sockets</a>, <a href="#force-ssl">SSL</a>, <a href="#cont">continuable
uploads</a>, <a href="#form-data">file uploads</a>, <a href="#cookie-jar-param">cookies</a>, and other
things. And it's probably a result of
my <a href="http://en.wikipedia.org/wiki/Not_Invented_Here">NIH
syndrome</a>...
<p>
Drakma was developed and tested
with <a href="http://www.lispworks.com/">LispWorks</a>, but it should
also work with a couple of other Common Lisp implementations depending
on the <a href="#download">supporting libraries</a>. Some tests
with <a href="http://www.sbcl.org/">SBCL</a> seem to confirm this.
<p>
The code comes with
a <a
href="http://www.opensource.org/licenses/bsd-license.php">BSD-style
license</a> so you can basically do with it whatever you want.
<p>
<font color=red>Download shortcut:</font> <a href="http://weitz.de/files/drakma.tar.gz">http://weitz.de/files/drakma.tar.gz</a>.
</blockquote>
<br> <br><h3><a class=none name="contents">Contents</a></h3>
<ol>
<li><a href="#example">Examples</a>
<li><a href="#download">Download and installation</a>
<li><a href="#mail">Support and mailing lists</a>
<li><a href="#dictionary">The Drakma dictionary</a>
<ol>
<li><a href="#request">The request</a>
<ol>
<li><a href="#http-request"><code>http-request</code></a>
<li><a href="#*drakma-default-external-format*"><code>*drakma-default-external-format*</code></a>
<li><a href="#*text-content-types*"><code>*text-content-types*</code></a>
<li><a href="#*body-format-function*"><code>*body-format-function*</code></a>
<li><a href="#*header-stream*"><code>*header-stream*</code></a>
</ol>
<li><a href="#cookies">Cookies</a>
<ol>
<li><a href="#cookie"><code>cookie</code></a>
<li><a href="#cookie-name"><code>cookie-name</code></a>
<li><a href="#cookie-value"><code>cookie-value</code></a>
<li><a href="#cookie-domain"><code>cookie-domain</code></a>
<li><a href="#cookie-path"><code>cookie-path</code></a>
<li><a href="#cookie-expires"><code>cookie-expires</code></a>
<li><a href="#cookie-securep"><code>cookie-securep</code></a>
<li><a href="#cookie-http-only-p"><code>cookie-http-only-p</code></a>
<li><a href="#cookie-jar"><code>cookie-jar</code></a>
<li><a href="#cookie-jar-cookies"><code>cookie-jar-cookies</code></a>
<li><a href="#cookie="><code>cookie=</code></a>
<li><a href="#delete-old-cookies"><code>delete-old-cookies</code></a>
<li><a href="#*allow-dotless-cookie-domains-p*"><code>*allow-dotless-cookie-domains-p*</code></a>
<li><a href="#*ignore-unparseable-cookie-dates-p*"><code>*ignore-unparseable-cookie-dates-p*</code></a>
<li><a href="#*remove-duplicate-cookies-p*"><code>*remove-duplicate-cookies-p*</code></a>
<li><a href="#parse-cookie-date"><code>parse-cookie-date</code></a>
</ol>
<li><a href="#headers">Headers</a>
<ol>
<li><a href="#header-value"><code>header-value</code></a>
<li><a href="#split-tokens"><code>split-tokens</code></a>
<li><a href="#read-tokens-and-parameters"><code>read-tokens-and-parameters</code></a>
<li><a href="#parameter-present-p"><code>parameter-present-p</code></a>
<li><a href="#parameter-value"><code>parameter-value</code></a>
<li><a href="#get-content-type"><code>get-content-type</code></a>
</ol>
<li><a href="#conditions">Conditions</a>
<ol>
<li><a href="#drakma-condition"><code>drakma-condition</code></a>
<li><a href="#drakma-error"><code>drakma-error</code></a>
<li><a href="#drakma-warning"><code>drakma-warning</code></a>
<li><a href="#syntax-error"><code>syntax-error</code></a>
<li><a href="#parameter-error"><code>parameter-error</code></a>
<li><a href="#cookie-error"><code>cookie-error</code></a>
<li><a href="#cookie-error-cookie"><code>cookie-error-cookie</code></a>
<li><a href="#cookie-date-parse-error"><code>cookie-date-parse-error</code></a>
</ol>
</ol>
<li><a href="#prob">Potential problems</a>
<li><a href="#ack">Acknowledgements</a>
</ol>
<br> <br><h3><a class=none name="example">Examples</a></h3>
Here's an example session with Drakma 0.3.0 which demonstrates
some of its features. (Some linebreaks were added or removed to
enhance legibility.) Note that this doesn't necessarily reflect the
current versions of Drakma and Hunchentoot. The examples should work
nevertheless - kind of...
<pre>
<font color=orange>;; create a log file of this sessions</font>
<font color=red>CL-USER 1 ></font> (<a class=noborder href="http://www.lispworks.com/documentation/HyperSpec/Body/f_dribbl.htm">dribble</a> "/tmp/drakma_dribble")
; Loading C:\Program Files\LispWorks\lib\5-0-0-0\load-on-demand\ccl\dribble.ofasl on demand...
<font color=orange>;; load Drakma</font>
<font color=red>CL-USER 2 ></font> (<a class=noborder href="http://www.cliki.net/asdf">asdf</a>:oos 'asdf:load-op :drakma)
; loading system definition from c:\home\lisp\drakma\drakma.asd into
; #<The ASDF0 package, 0/16 internal, 0/16 external>
; Loading text file c:\home\lisp\drakma\drakma.asd
; registering #<SYSTEM :DRAKMA 21D6D24F> as DRAKMA
;; Creating system COMMON-LISP-USER::DRAKMA
; loading system definition from c:\home\lisp\<a class=noborder href="http://globalia.net/donlope/fz/songs/Chunga's_Revenge.html">chunga</a>\chunga.asd into
; #<The ASDF0 package, 0/16 internal, 0/16 external>
; Loading text file c:\home\lisp\chunga\chunga.asd
; registering #<SYSTEM :CHUNGA 200B12A3> as CHUNGA
;; Creating system COMMON-LISP-USER::CHUNGA
; loading system definition from c:\home\lisp\flexi-streams\flexi-streams.asd into
; #<The ASDF0 package, 0/16 internal, 0/16 external>
; Loading text file c:\home\lisp\flexi-streams\flexi-streams.asd
; registering #<SYSTEM :FLEXI-STREAMS 200E8017> as FLEXI-STREAMS
;; Creating system COMMON-LISP-USER::FLEXI-STREAMS
; loading system definition from c:\home\lisp\trivial-gray-streams\trivial-gray-streams.asd into
; #<The ASDF0 package, 0/16 internal, 0/16 external>
; Loading text file c:\home\lisp\trivial-gray-streams\trivial-gray-streams.asd
; registering #<SYSTEM :TRIVIAL-GRAY-STREAMS 21D6741F> as TRIVIAL-GRAY-STREAMS
;; Creating system COMMON-LISP-USER::TRIVIAL-GRAY-STREAMS
; loading system definition from c:\home\lisp\cl-base64-3.3.2\cl-base64.asd into
; #<The ASDF0 package, 0/16 internal, 0/16 external>
; Loading text file c:\home\lisp\cl-base64-3.3.2\cl-base64.asd
; registering #<SYSTEM CL-BASE64 21D6D277> as CL-BASE64
;; Creating system COMMON-LISP-USER::CL-BASE64
; registering #<SYSTEM CL-BASE64-TESTS 2009701B> as CL-BASE64-TESTS
;; Creating system COMMON-LISP-USER::CL-BASE64-TESTS
; loading system definition from c:\home\lisp\puri-1.5\puri.asd into
; #<The ASDF0 package, 0/16 internal, 0/16 external>
; Loading text file c:\home\lisp\puri-1.5\puri.asd
; registering #<SYSTEM PURI 21D6B093> as PURI
;; Creating system COMMON-LISP-USER::PURI
; registering #<SYSTEM PURI-TESTS 200CFEEF> as PURI-TESTS
;; Creating system COMMON-LISP-USER::PURI-TESTS
; Loading fasl file c:\home\lisp\trivial-gray-streams\package.ofasl
; Loading fasl file c:\home\lisp\trivial-gray-streams\mixin.ofasl
; Loading fasl file c:\home\lisp\flexi-streams\packages.ofasl
; Loading fasl file c:\home\lisp\flexi-streams\ascii.ofasl
; Loading fasl file c:\home\lisp\flexi-streams\iso-8859.ofasl
; Loading fasl file c:\home\lisp\flexi-streams\code-pages.ofasl
; Loading fasl file c:\home\lisp\flexi-streams\specials.ofasl
; Loading fasl file c:\home\lisp\flexi-streams\util.ofasl
; Loading fasl file c:\home\lisp\flexi-streams\external-format.ofasl
; Loading fasl file c:\home\lisp\flexi-streams\in-memory.ofasl
; Loading fasl file c:\home\lisp\flexi-streams\stream.ofasl
; Loading fasl file c:\home\lisp\flexi-streams\output.ofasl
; Loading fasl file c:\home\lisp\flexi-streams\input.ofasl
; Loading fasl file c:\home\lisp\flexi-streams\strings.ofasl
; Loading fasl file c:\home\lisp\chunga\packages.ofasl
; Loading fasl file c:\home\lisp\chunga\specials.ofasl
; Loading fasl file c:\home\lisp\chunga\util.ofasl
; Loading fasl file c:\home\lisp\chunga\read.ofasl
; Loading fasl file c:\home\lisp\chunga\streams.ofasl
; Loading fasl file c:\home\lisp\chunga\input.ofasl
; Loading fasl file c:\home\lisp\chunga\output.ofasl
; Loading fasl file c:\home\lisp\cl-base64-3.3.2\package.ofasl
; Loading fasl file c:\home\lisp\cl-base64-3.3.2\encode.ofasl
; Loading fasl file c:\home\lisp\cl-base64-3.3.2\decode.ofasl
; Loading fasl file c:\home\lisp\puri-1.5\src.ofasl
; Loading fasl file c:\home\lisp\drakma\packages.ofasl
; Loading fasl file c:\home\lisp\drakma\specials.ofasl
; Loading fasl file c:\home\lisp\drakma\util.ofasl
; Loading c:\Program Files\LispWorks\lib\5-0-0-0\load-on-demand\processes\comm-defsys.lisp on demand...
;; Creating system COMM
; Loading text file c:\Program Files\LispWorks\lib\5-0-0-0\load-on-demand\processes\comm-pkg.lisp
; Loading fasl file c:\Program Files\LispWorks\lib\5-0-0-0\load-on-demand\processes\sockets.ofasl
; Loading fasl file c:\Program Files\LispWorks\lib\5-0-0-0\load-on-demand\processes\ssl-constants.ofasl
; Loading fasl file c:\Program Files\LispWorks\lib\5-0-0-0\load-on-demand\processes\ssl-foreign-types.ofasl
; Loading fasl file c:\Program Files\LispWorks\lib\5-0-0-0\load-on-demand\processes\ssl.ofasl
; Loading fasl file c:\Program Files\LispWorks\lib\5-0-0-0\load-on-demand\processes\ssl-certs.ofasl
; Loading fasl file c:\Program Files\LispWorks\lib\5-0-0-0\patches\comm\0001\0001.ofasl
; Loaded public patch COMM 1.1
; Loading fasl file c:\Program Files\LispWorks\lib\5-0-0-0\patches\comm\0001\0002.ofasl
; Loaded public patch COMM 1.2
; Loading fasl file c:\Program Files\LispWorks\lib\5-0-0-0\patches\comm\0001\0003.ofasl
; Loaded public patch COMM 1.3
; Loading fasl file c:\Program Files\LispWorks\lib\5-0-0-0\patches\comm\0001\0004.ofasl
; Loaded public patch COMM 1.4
; Loading fasl file c:\home\lisp\drakma\read.ofasl
; Loading fasl file c:\home\lisp\drakma\cookies.ofasl
; Loading fasl file c:\home\lisp\drakma\request.ofasl
NIL
<font color=orange>;; create a package to work in</font>
<font color=red>CL-USER 3 ></font> (<a href="http://www.lispworks.com/documentation/HyperSpec/Body/m_defpkg.htm" class=noborder>defpackage</a> :drakma-user (:use :cl :drakma))
#<The DRAKMA-USER package, 0/16 internal, 0/16 external>
<font color=orange>;; switch to this package</font>
<font color=red>CL-USER 4 ></font> (<a href="http://www.lispworks.com/documentation/HyperSpec/Body/m_in_pkg.htm" class=noborder>in-package</a> :drakma-user)
#<The DRAKMA-USER package, 0/16 internal, 0/16 external>
<font color=orange>;; log headers, so we can see what happens -
;; output to <a class=noborder href="#*header-stream*"><code><font color=orange>*HEADER-STREAM*</font></code></a> will be shown in <font color=green>green</font> below</font>
<font color=red>DRAKMA-USER 5 ></font> (setq <a class=noborder href="#*header-stream*">*header-stream*</a> <a href="http://www.lispworks.com/documentation/HyperSpec/Body/v_debug_.htm" class=noborder>*standard-output*</a>)
#<Broadcast stream to (#<Echo Stream Input = #<EDITOR::RUBBER-STREAM #<EDITOR:BUFFER CAPI interactive-pane 2> 2198ECD7>,
Output = #<STREAM::LATIN-1-FILE-STREAM c:\tmp\drakma_dribble>>
#<EDITOR::RUBBER-STREAM #<EDITOR:BUFFER CAPI interactive-pane 2> 2198ECD7>)>
<font color=orange>;; note how Drakma automatically follows the 301 redirect and how the fourth return value shows the <em>new</em> URI</font>
<font color=red>DRAKMA-USER 6 ></font> (<a class=noborder href="#http-request">http-request</a> "<a href="http://lisp.org/" class=noborder>http://lisp.org/</a>")
<font color=green>GET / HTTP/1.1
Host: lisp.org
User-Agent: Drakma/0.3.0 (LispWorks 5.0.0; Windows NT; Windows XP: 5.1 (build 2600) Service Pack 2; http://weitz.de/drakma/)
Accept: */*
Connection: close
HTTP/1.1 301 Moved Permanently
Date: Sat, 26 Aug 2006 15:46:31 GMT
Connection: Close
Server: <a href="http://opensource.franz.com/aserve/" class=noborder>AllegroServe</a>/1.2.37
Transfer-Encoding: chunked
LOCATION: /index.html
GET /index.html HTTP/1.1
Host: lisp.org
User-Agent: Drakma/0.3.0 (LispWorks 5.0.0; Windows NT; Windows XP: 5.1 (build 2600) Service Pack 2; http://weitz.de/drakma/)
Accept: */*
Connection: close
HTTP/1.1 200 OK
Date: Sat, 26 Aug 2006 15:46:32 GMT
Connection: Close
Server: AllegroServe/1.2.37
Content-Type: text/html
Content-Length: 82
LAST-MODIFIED: Mon, 16 Feb 2004 09:30:02 GMT</font>
"<title>redirect...</title>
<meta http-equiv=\"Refresh\" content=\"0; url=/alu/home\">
"
200
((:DATE . "Sat, 26 Aug 2006 15:46:32 GMT")
(:CONNECTION . "Close")
(:SERVER . "AllegroServe/1.2.37")
(:CONTENT-TYPE . "text/html")
(:CONTENT-LENGTH . "82")
(:LAST-MODIFIED . "Mon, 16 Feb 2004 09:30:02 GMT"))
#<URI http://lisp.org/index.html>
#<FLEXI-STREAMS:FLEXI-IO-STREAM 201017D3>
T
<font color=orange>;; here, Drakma automatically interprets the 'charset=utf-8' part correctly -
;; might look a bit different in your listener depending on the font you've chosen</font>
<font color=red>DRAKMA-USER 7 ></font> (<a href="http://www.lispworks.com/documentation/HyperSpec/Body/f_subseq.htm" class=noborder>subseq</a> (<a class=noborder href="#http-request">http-request</a> "<a href="http://www.cl.cam.ac.uk/~mgk25/ucs/examples/digraphs.txt" class=noborder>http://www.cl.cam.ac.uk/~mgk25/ucs/examples/digraphs.txt</a>") 0 298)
<font color=green>GET /~mgk25/ucs/examples/digraphs.txt HTTP/1.1
Host: www.cl.cam.ac.uk
User-Agent: Drakma/0.3.0 (LispWorks 5.0.0; Windows NT; Windows XP: 5.1 (build 2600) Service Pack 2; http://weitz.de/drakma/)
Accept: */*
Connection: close
HTTP/1.1 200 OK
Date: Sat, 26 Aug 2006 16:02:56 GMT
Server: Apache/1.3.37 (Unix) mod_ucam_webauth/1.2.2
Last-Modified: Thu, 05 Jan 2006 20:49:55 GMT
ETag: "17cd62-298-43bd8673"
Accept-Ranges: bytes
Content-Length: 664
Connection: close
Content-Type: text/plain; charset=utf-8</font>
"Latin Digraphs and Ligatures in ISO10646-1
A short table of ligatures and digraphs follows. Some of these may not be
ligatures/digraphs in the technical sense, (for example, æ is a seperate
letter in English), but visually they behave that way.
AÆE : U+00C6
aæe : U+00E6
ſßs : U+00DF
IIJJ : U+0132"
<font color=orange>;; a vector of octets is returned for (non-text) binary data - a picture in this case</font>
<font color=red>DRAKMA-USER 8 ></font> (<a class=noborder href="#http-request">http-request</a> "<a href="http://zappa.com/favicon.ico" class=noborder>http://zappa.com/favicon.ico</a>")
<font color=green>GET /favicon.ico HTTP/1.1
Host: zappa.com
User-Agent: Drakma/0.3.0 (LispWorks 5.0.0; Windows NT; Windows XP: 5.1 (build 2600) Service Pack 2; http://weitz.de/drakma/)
Accept: */*
Connection: close
HTTP/1.1 200 OK
Date: Sat, 26 Aug 2006 16:02:59 GMT
Server: Apache/2.0.46 (Red Hat)
Last-Modified: Fri, 17 Mar 2006 08:11:07 GMT
ETag: "3a4080-b6-59d5bcc0"
Accept-Ranges: bytes
Content-Length: 182
Connection: close
Content-Type: image/gif</font>
#(71 73 70 56 57 97 17 0 17 0 179 1 0 150 151 153 255 255 255 37 37 36 112 114 115
201 202 204 0 0 0 80 83 84 26 28 26 230 231 231 249 249 249 12 13 14 219 221 222
18 21 22 239 240 241 52 52 54 64 66 66 33 249 4 1 0 0 1 0 44 0 0 0 0 17 0 17 0 0
4 99 48 200 73 107 109 54 172 101 129 120 196 180 12 12 51 80 64 161 42 3 48 28
170 106 72 141 16 223 120 113 166 121 95 0 14 95 239 33 236 41 98 10 129 114 185
188 29 127 25 201 224 73 60 4 8 0 130 22 59 64 52 96 135 148 35 96 80 152 159 186
192 64 183 112 0 200 61 65 0 1 192 76 214 185 113 102 241 88 26 90 8 81 18 8 94
130 134 22 17 0 59)
200
((:DATE . "Sat, 26 Aug 2006 16:02:59 GMT")
(:SERVER . "Apache/2.0.46 (Red Hat)")
(:LAST-MODIFIED . "Fri, 17 Mar 2006 08:11:07 GMT")
(:ETAG . "\"3a4080-b6-59d5bcc0\"")
(:ACCEPT-RANGES . "bytes")
(:CONTENT-LENGTH . "182")
(:CONNECTION . "close")
(:CONTENT-TYPE . "image/gif"))
#<URI http://zappa.com/favicon.ico>
#<FLEXI-STREAMS:FLEXI-IO-STREAM 200D59BF>
T
<font color=orange>;; a secure connection (see <a class=noborder href="#download"><font color=orange>below</font></a>) -
;; also note that the server uses <a class=noborder name="chunked" href="http://www.rfc.net/rfc2616.html#s3.6.1"><font color=orange>chunked transfer encoding</font></a> for its reply</font>
<font color=red>DRAKMA-USER 9 ></font> (<a class=noborder href="http://weitz.de/cl-ppcre/">ppcre</a>:<a class=noborder href="http://weitz.de/cl-ppcre/#scan-to-strings">scan-to-strings</a> "(?s)You have.*your data."
(<a class=noborder href="#http-request">http-request</a> "<a href="https://www.fortify.net/cgi/ssl_2.pl" class=noborder>https://www.fortify.net/cgi/ssl_2.pl</a>"))
<font color=green>GET /cgi/ssl_2.pl HTTP/1.1
Host: www.fortify.net
User-Agent: Drakma/0.3.0 (LispWorks 5.0.0; Windows NT; Windows XP: 5.1 (build 2600) Service Pack 2; http://weitz.de/drakma/)
Accept: */*
Connection: close
HTTP/1.1 200 OK
Date: Sat, 26 Aug 2006 16:10:06 GMT
Server: Apache
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html</font>
"You have connected to this web server using the DHE-RSA-AES256-SHA encryption cipher
with a key length of 256 bits.
<p>
This is a high-grade encryption connection, regarded by most experts as being suitable
for sending or receiving even the most sensitive or valuable information
across a network.
<p>
In a crude analogy, using this cipher is similar to sending or storing your data inside
a high quality safe - compared to an export-grade cipher which is similar to using
a paper envelope to protect your data."
#()
<font color=orange>;; using a different 'User-Agent' header</font>
<font color=red>DRAKMA-USER 10 ></font> (<a class=noborder href="http://weitz.de/cl-ppcre/">ppcre</a>:<a class=noborder href="http://weitz.de/cl-ppcre/#regex-replace-all">regex-replace-all</a>
"<.*?>"
(<a class=noborder href="http://weitz.de/cl-ppcre/">ppcre</a>:<a class=noborder href="http://weitz.de/cl-ppcre/#scan-to-strings">scan-to-strings</a> "(?s)Your browser reports.*?</table>"
(<a class=noborder href="#http-request">http-request</a> "<a class=noborder href="http://bcheck.scanit.be/bcheck/">http://bcheck.scanit.be/bcheck/</a>"
:user-agent :explorer))
"")
<font color=green>GET /bcheck/ HTTP/1.1
Host: bcheck.scanit.be
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
Accept: */*
Connection: close
HTTP/1.1 200 OK
Date: Sat, 26 Aug 2006 16:21:50 GMT
Server: Apache
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html</font>
"Your browser reports to be:
Browser name: MSIE
Version: 6.0
Platform: Windows NT 5.1
"
<font color=orange>;; sending parameters in a POST request and working with <a href="#cookie" class=noborder><font color=orange>cookies</font></a> -
;; note how Drakma sends the cookie back in the second request</font>
<font color=red>DRAKMA-USER 11 ></font> (let ((cookie-jar (<a href="http://www.lispworks.com/documentation/HyperSpec/Body/f_mk_ins.htm" class=noborder>make-instance</a> '<a class=noborder href="#cookie-jar">cookie-jar</a>)))
(<a class=noborder href="#http-request">http-request</a> "<a class=noborder href="http://www.phpsecurepages.com/test/test.php">http://www.phpsecurepages.com/test/test.php</a>"
:method :post
:parameters '(("entered_login" . "test")
("entered_password" . "test"))
:cookie-jar cookie-jar)
(<a class=noborder href="#http-request">http-request</a> "<a class=noborder href="http://www.phpsecurepages.com/test/test2.php">http://www.phpsecurepages.com/test/test2.php</a>"
:cookie-jar cookie-jar)
(<a class=noborder href="#cookie-jar-cookies">cookie-jar-cookies</a> cookie-jar))
<font color=green>POST /test/test.php HTTP/1.1
Host: www.phpsecurepages.com
User-Agent: Drakma/0.3.0 (LispWorks 5.0.0; Windows NT; Windows XP: 5.1 (build 2600) Service Pack 2; http://weitz.de/drakma/)
Accept: */*
Content-Length: 40
Content-Type: application/x-www-form-urlencoded
Connection: close
HTTP/1.1 200 OK
Date: Sat, 26 Aug 2006 18:26:17 GMT
Server: Apache/2.0.51 (Fedora)
X-Powered-By: PHP/4.3.10
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: PHPSESSID=3ce33aa3e326ab4bf5da7feecc3248b4; path=/
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html
GET /test/test2.php HTTP/1.1
Host: www.phpsecurepages.com
User-Agent: Drakma/0.3.0 (LispWorks 5.0.0; Windows NT; Windows XP: 5.1 (build 2600) Service Pack 2; http://weitz.de/drakma/)
Accept: */*
Cookie: PHPSESSID=3ce33aa3e326ab4bf5da7feecc3248b4
Connection: close
HTTP/1.1 200 OK
Date: Sat, 26 Aug 2006 18:26:18 GMT
Server: Apache/2.0.51 (Fedora)
X-Powered-By: PHP/4.3.10
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html</font>
(#<<a href="#cookie" class=noborder>COOKIE</a> PHPSESSID=3ce33aa3e326ab4bf5da7feecc3248b4; path=/; domain=www.phpsecurepages.com>)
<font color=orange>;; now we are going to <a name="re-use" class=noborder>re-use</a> a socket for the second connection to the same server
;; this will also work with chunked encoding</font>
<font color=red>DRAKMA-USER 12 ></font> (let ((stream (<a class=noborder href="http://www.lispworks.com/documentation/HyperSpec/Body/m_nth_va.htm">nth-value</a> 4 (<a class=noborder href="#http-request">http-request</a> "<a class=noborder href="http://www.lispworks.com/">http://www.lispworks.com/</a>" :close nil))))
(nth-value 2 (<a class=noborder href="#http-request">http-request</a> "<a class=noborder href="http://www.lispworks.com/success-stories/index.html">http://www.lispworks.com/success-stories/index.html</a>"
:stream stream)))
<font color=green>GET / HTTP/1.1
Host: www.lispworks.com
User-Agent: Drakma/0.3.0 (LispWorks 5.0.0; Windows NT; Windows XP: 5.1 (build 2600) Service Pack 2; http://weitz.de/drakma/)
Accept: */*
HTTP/1.1 200 OK
Date: Sat, 26 Aug 2006 18:34:20 GMT
Server: Apache/1.3.37 Ben-SSL/1.57 (Unix)
Last-Modified: Tue, 08 Aug 2006 18:20:49 GMT
ETag: "28ee4f0-22db-44d8d601"
Accept-Ranges: bytes
Content-Length: 8923
Content-Type: text/html
GET /success-stories/index.html HTTP/1.1
Host: www.lispworks.com
User-Agent: Drakma/0.3.0 (LispWorks 5.0.0; Windows NT; Windows XP: 5.1 (build 2600) Service Pack 2; http://weitz.de/drakma/)
Accept: */*
Connection: close
HTTP/1.1 200 OK
Date: Sat, 26 Aug 2006 18:34:20 GMT
Server: Apache/1.3.37 Ben-SSL/1.57 (Unix)
Last-Modified: Tue, 08 Aug 2006 18:22:19 GMT
ETag: "28f3f42-2325-44d8d65b"
Accept-Ranges: bytes
Content-Length: 8997
Connection: close
Content-Type: text/html</font>
((:DATE . "Sat, 26 Aug 2006 18:34:20 GMT")
(:SERVER . "Apache/1.3.37 Ben-SSL/1.57 (Unix)")
(:LAST-MODIFIED . "Tue, 08 Aug 2006 18:22:19 GMT")
(:ETAG . "\"28f3f42-2325-44d8d65b\"")
(:ACCEPT-RANGES . "bytes")
(:CONTENT-LENGTH . "8997")
(:CONNECTION . "close")
(:CONTENT-TYPE . "text/html"))
<font color=orange>;; testing basic authorization against a local <a href="http://weitz.de/hunchentoot/" class=noborder><font color=orange>Hunchentoot</font></a> server</font>
<font color=red>DRAKMA-USER 13 ></font> (<a class=noborder href="http://www.lispworks.com/documentation/HyperSpec/Body/m_nth_va.htm">nth-value</a> 1 (<a class=noborder href="#http-request">http-request</a> "http://localhost:4242/<a class=noborder href="http://weitz.de/tbnl/#test">tbnl/test</a>/authorization.html"))
<font color=green>GET /tbnl/test/authorization.html HTTP/1.1
Host: localhost:4242
User-Agent: Drakma/0.3.0 (LispWorks 5.0.0; Windows NT; Windows XP: 5.1 (build 2600) Service Pack 2; http://weitz.de/drakma/)
Accept: */*
Connection: close
HTTP/1.1 401 Authorization Required
Content-Length: 563
Content-Type: text/html; charset=iso-8859-1
Date: Sat, 26 Aug 2006 18:38:58 GMT
Server: <a class=noborder href="http://weitz.de/hunchentoot/">Hunchentoot</a> 0.1.5 (<a href="http://weitz.de/tbnl/" class=noborder>TBNL</a> 0.10.0)
Connection: Close
WWW-Authenticate: Basic realm="TBNL"</font>
401
<font color=red>DRAKMA-USER 14 ></font> (<a class=noborder href="http://www.lispworks.com/documentation/HyperSpec/Body/m_nth_va.htm">nth-value</a> 1 (<a class=noborder href="#http-request">http-request</a> "http://localhost:4242/<a class=noborder href="http://weitz.de/tbnl/#test">tbnl/test</a>/authorization.html"
:basic-authorization '("nanook" "igloo")))
<font color=green>GET /tbnl/test/authorization.html HTTP/1.1
Host: localhost:4242
User-Agent: Drakma/0.3.0 (LispWorks 5.0.0; Windows NT; Windows XP: 5.1 (build 2600) Service Pack 2; http://weitz.de/drakma/)
Authorization: Basic bmFub29rOmlnbG9v
Accept: */*
Connection: close
HTTP/1.1 200 OK
Content-Length: 884
Content-Type: text/html; charset=iso-8859-1
Date: Sat, 26 Aug 2006 18:39:19 GMT
Server: <a class=noborder href="http://weitz.de/hunchentoot/">Hunchentoot</a> 0.1.5 (<a href="http://weitz.de/tbnl/" class=noborder>TBNL</a> 0.10.0)
Connection: Close</font>
200
<font color=orange>;; now we ask Drakma to return a stream and read from it directly</font>
<font color=red>DRAKMA-USER 15 ></font> (<a href="http://www.lispworks.com/documentation/HyperSpec/Body/s_let_l.htm" class=noborder>let</a> ((stream (<a class=noborder href="#http-request">http-request</a> "<a href="http://www.jalat.com/blogs/lisp?id=3" class=noborder>http://www.jalat.com/blogs/lisp?id=3</a>"
:want-stream t)))
(<a href="http://www.lispworks.com/documentation/HyperSpec/Body/06_a.htm" class=noborder>loop</a> for i below 41
for line = (<a href="http://www.lispworks.com/documentation/HyperSpec/Body/f_rd_lin.htm" class=noborder>read-line</a> stream)
when (> i 35)
do (<a href="http://www.lispworks.com/documentation/HyperSpec/Body/f_wr_stg.htm" class=noborder>write-line</a> line))
(<a href="http://www.lispworks.com/documentation/HyperSpec/Body/f_close.htm" class=noborder>close</a> stream)
(<a href="http://www.lispworks.com/documentation/HyperSpec/Body/a_values.htm" class=noborder>values</a>))
<font color=green>GET /blogs/lisp?id=3 HTTP/1.1
Host: www.jalat.com
User-Agent: Drakma/0.3.0 (LispWorks 5.0.0; Windows NT; Windows XP: 5.1 (build 2600) Service Pack 2; http://weitz.de/drakma/)
Accept: */*
Connection: close
HTTP/1.1 200 OK
Content-Length: 21453
Content-Type: text/html; charset=iso-8859-1
Date: Sat, 26 Aug 2006 19:53:37 GMT
Server: <a href="http://weitz.de/hunchentoot/" class=noborder>Hunchentoot</a> 0.1.3 (<a href="http://weitz.de/tbnl/" class=noborder>TBNL</a> 0.9.7)
Connection: Close</font>
Bill Clementson has <a
href="<a href="http://bc.tech.coop/blog/041111.html" class=noborder>http://bc.tech.coop/blog/041111.html</a>">written</a> about getting
<a href="http://weitz.de/tbnl/" class=noborder>TBNL</a> up and running with <a href="http://httpd.apache.org/" class=noborder>apache</a> and <a href="http://www.fractalconcept.com/asp/html/mod_lisp.html" class=noborder>mod_lisp</a>. In this example I'm
going to use <a href="<a href="http://weitz.de/hunchentoot/" class=noborder>http://weitz.de/hunchentoot/</a>">hunchentoot</a>, a
pure lisp web server by (again) Edi Weitz.
<font color=orange><a class=noborder name="cont">;; let's test a POST request without content length and with chunked transfer encoding -</a>
;; we build the content in several steps using different types of data
;; (note: doesn't work anymore, probably due to server changes)</font>
<font color=red>DRAKMA-USER 16 ></font> (let ((temp-file (<a href="http://www.lispworks.com/documentation/HyperSpec/Body/f_ensu_1.htm" class=noborder>ensure-directories-exist</a> #p"/tmp/quux.txt"))
(continuation (<a href="#http-request" class=noborder>http-request</a> "<a href="http://meme.b9.com/login.html" class=noborder>http://meme.b9.com/login.html</a>"
:method :post
:content :continuation)))
(<a href="http://www.lispworks.com/documentation/HyperSpec/Body/f_funcal.htm" class=noborder>funcall</a> continuation "username=" t)
(funcall continuation (<a href="http://www.lispworks.com/documentation/HyperSpec/Body/f_list_.htm" class=noborder>list</a> (<a href="http://www.lispworks.com/documentation/HyperSpec/Body/f_char_c.htm" class=noborder>char-code</a> #\n) (char-code #\a)) t)
(funcall continuation (<a href="http://www.lispworks.com/documentation/HyperSpec/Body/m_lambda.htm" class=noborder>lambda</a> (stream)
(<a href="http://www.lispworks.com/documentation/HyperSpec/Body/f_wr_cha.htm" class=noborder>write-char</a> #\n stream)) t)
(<a href="http://www.lispworks.com/documentation/HyperSpec/Body/m_w_open.htm" class=noborder>with-open-file</a> (out temp-file
:direction :output
:if-does-not-exist :create
:if-exists :supersede)
(<a href="http://www.lispworks.com/documentation/HyperSpec/Body/f_wr_stg.htm" class=noborder>write-string</a> "ook" out))
(funcall continuation temp-file t)
(<a href="http://weitz.de/cl-ppcre/" class=noborder>ppcre</a>:<a href="http://weitz.de/cl-ppcre/#scan-to-strings" class=noborder>scan-to-strings</a> "(?i)[a-z ]+nanook[a-z .]+"
(funcall continuation "&password=igloo")))
<font color=green>POST /login.html HTTP/1.1
Host: meme.b9.com
User-Agent: Drakma/0.3.0 (LispWorks 5.0.0; Windows NT; Windows XP: 5.1 (build 2600) Service Pack 2; http://weitz.de/drakma/)
Accept: */*
Connection: close
Content-Type: application/x-www-form-urlencoded
Transfer-Encoding: chunked
HTTP/1.0 200 OK
Date: Sat, 02 Sep 2006 00:25:24 GMT
Connection: close
Server: AllegroServe/1.2.45
Content-Type: text/html
Content-Length: 2922
PRAGMA: no-cache
CACHE-CONTROL: no-cache
SET-COOKIE: meme=1834b91d26f9be983a0ed9ca; path=/</font>
"The username nanook is not in our database."
#()
<font color=orange>;; finally, we send additional headers to ask for a <a href="http://www.rfc.net/rfc2616.html#s14.35" class=noborder><font color=orange>range</font></a></font>
<font color=red>DRAKMA-USER 17 ></font> (<a href="http://weitz.de/cl-ppcre/" class=noborder>ppcre</a>:<a class=noborder href="http://weitz.de/cl-ppcre/#regex-replace-all">regex-replace-all</a>
"<.*?>"
(<a href="http://www.lispworks.com/documentation/HyperSpec/Body/22_c.htm" class=noborder>format</a> nil "~A~A"
(<a class=noborder href="#http-request">http-request</a> "<a href="http://users.cableaz.com/~lantz/pages/hunchentoot.html" class=noborder>http://users.cableaz.com/~lantz/pages/hunchentoot.html</a>"
:additional-headers '(("<a href="http://www.rfc.net/rfc2616.html#s14.35" class=noborder>Range</a>" . "bytes=959-999")))
(<a class=noborder href="#http-request">http-request</a> "<a href="http://users.cableaz.com/~lantz/pages/hunchentoot.html" class=noborder>http://users.cableaz.com/~lantz/pages/hunchentoot.html</a>"
:additional-headers '(("<a href="http://www.rfc.net/rfc2616.html#s14.35" class=noborder>Range</a>" . "bytes=1165-1201"))))
"")
<font color=green>GET /~lantz/pages/hunchentoot.html HTTP/1.1
Host: users.cableaz.com
User-Agent: Drakma/0.3.0 (LispWorks 5.0.0; Windows NT; Windows XP: 5.1 (build 2600) Service Pack 2; http://weitz.de/drakma/)
Accept: */*
Connection: close
Range: bytes=959-999
HTTP/1.1 206 Partial Content
Date: Sat, 26 Aug 2006 19:07:44 GMT
Server: Apache/2.0.16 (Unix)
Last-Modified: Sun, 24 Apr 2005 04:08:45 GMT
ETag: "35298d-2fea-d8f4cd40"
Accept-Ranges: bytes
Content-Length: 41
Content-Range: bytes 959-999/12266
Content-Type: text/html; charset=ISO-8859-1
Connection: close
GET /~lantz/pages/hunchentoot.html HTTP/1.1
Host: users.cableaz.com
User-Agent: Drakma/0.3.0 (LispWorks 5.0.0; Windows NT; Windows XP: 5.1 (build 2600) Service Pack 2; http://weitz.de/drakma/)
Accept: */*
Connection: close
Range: bytes=1165-1201
HTTP/1.1 206 Partial Content
Date: Sat, 26 Aug 2006 19:07:45 GMT
Server: Apache/2.0.16 (Unix)
Last-Modified: Sun, 24 Apr 2005 04:08:45 GMT
ETag: "35298d-2fea-d8f4cd40"
Accept-Ranges: bytes
Content-Length: 37
Content-Range: bytes 1165-1201/12266
Content-Type: text/html; charset=ISO-8859-1
Connection: close</font>
"<a href="http://weitz.de/drakma/" class=noborder>DRAKMA</a> (Queen of Cosmic Greed)
<a href="http://weitz.de/hunchentoot/" class=noborder>HUNCHENTOOT</a> (The Giant Spider)"
</pre>
<br> <br><h3><a class=none name="download">Download and installation</a></h3>
Drakma together with this documentation can be downloaded
from <a href="http://weitz.de/files/drakma.tar.gz">http://weitz.de/files/drakma.tar.gz</a>.
The current version is 1.2.8. Drakma and all its dependencies can be
installed via <a href="http://www.quicklisp.org/">quicklisp</a>. It
depends on the open source
libraries <a href="http://www.cliki.net/cl-base64">CL-BASE64</a>, <a href="http://www.cliki.net/Puri">Puri</a>, <a href="http://weitz.de/flexi-streams/">FLEXI-STREAMS</a>,
<a href="http://weitz.de/cl-ppcre/">CL-PPCRE</a>,
and <a href="http://weitz.de/chunga/">Chunga</a>. If
you're <em>not</em> using LispWorks, you'll also
need <a href="http://www.cliki.net/usocket">usocket</a> and (except
for <a href="http://franz.com/products/allegrocl/">AllegroCL</a>) <a href="http://common-lisp.net/project/cl-plus-ssl/">CL+SSL</a>.
Try to use the <b>newest</b> versions of all these libraries. There's
a port of Drakma
for <a href="http://www.gentoo.org/proj/en/common-lisp/index.xml">Gentoo
Linux</a> thanks to Matthew Kennedy.
<p>
For <a
href="http://en.wikipedia.org/wiki/Secure_Sockets_Layer">SSL</a>, you
will need to
have <a
href="http://www.lispworks.com/documentation/lw50/LWUG/html/lwuser-344.htm">the
corresponding C libraries</a> as well. You'll usually have them
already unless you're on Windows. If you don't have required C libraries you can add <b>:drakma-no-ssl</b>
to <b>*features*</b> to avoid using CL+SSL for https support.
<p>
The current development version of Drakma can be found
at <a href="https://github.com/edicl/drakma">https://github.com/edicl/drakma</a>.
This is the one to send <a href="#mail">patches</a> against. Use at
your own risk.
<p>
Luís Oliveira maintains an
unofficial <a href="http://darcs.net/">darcs</a> repository of Drakma
at <a href="http://common-lisp.net/~loliveira/ediware/">http://common-lisp.net/~loliveira/ediware/</a>.
<p>
An
unofficial <a href="http://www.selenic.com/mercurial/wiki/">Mercurial</a>
repository of older versions is available
at <a href="http://arcanes.fr.eu.org/~pierre/2007/02/weitz/">http://arcanes.fr.eu.org/~pierre/2007/02/weitz/</a>
thanks to Pierre Thierry.
<br> <br><h3><a name="mail" class=none>Support and mailing lists</a></h3>
For questions, bug reports, feature requests, improvements, or patches
please use the <a
href="http://common-lisp.net/mailman/listinfo/drakma-devel">drakma-devel
mailing list</a>. If you want to be notified about future releases
subscribe to the <a
href="http://common-lisp.net/mailman/listinfo/drakma-announce">drakma-announce
mailing list</a>. These mailing lists were made available thanks to
the services of <a href="http://common-lisp.net/">common-lisp.net</a>.
<p>
If you want to send patches, please <a href="http://weitz.de/patches.html">read this first</a>.
<br> <br><h3><a class=none name="dictionary">The Drakma dictionary</a></h3>
<h4><a name="request" class=none>The request</a></h4>
The <a href="#http-request"><code>HTTP-REQUEST</code></a> function is
the heart of Drakma. It is used to send requests to web servers and
will either return the message body of the server's reply or (if the
user so wishes) a stream one can read from. The wealth of keyword
parameters might look a bit intimidating first, but you will rarely
need more than two or three of them - the default behaviour of Drakma
is (hopefully) designed to do The Right Thing[TM] in most cases.
<p>
You can use
the <a href="#*header-stream*"><code>*HEADER-STREAM*</code></a>
variable to debug requests handled by Drakma in a way similar
to <a href="http://livehttpheaders.mozdev.org/">LiveHTTPHeaders</a>.
<!-- Entry for HTTP-REQUEST -->
<p>
<br>
<table border=0>
<tr>
<td colspan=4 valign=top>[Function]</td>
</tr>
<tr>
<td valign=top style="white-space:nowrap"><a class=none name='http-request'><b>http-request</b></a> </td>
<td valign=top><i><a class=none href="#uri">uri</a> </i></td>
<td valign=top><tt>&key</tt> </td>
<td>
<i>
<a class=none href="#protocol">protocol</a>
<a class=none href="#method">method</a>
<a class=none href="#force-ssl">force-ssl</a>
<a class=none href="#certificate">certificate</a>
<a class=none href="#key">key</a>
<a class=none href="#certificate-password">certificate-password</a>
<a class=none href="#verify">verify</a>
<a class=none href="#max-depth">max-depth</a>
<a class=none href="#ca-file">ca-file</a>
<a class=none href="#ca-directory">ca-directory</a>
<a class=none href="#parameters">parameters</a>
<a class=none href="#form-data">form-data</a>
<a class=none href="#content">content</a>
<a class=none href="#content-length">content-length</a>
<a class=none href="#content-type">content-type</a>
<a class=none href="#cookie-jar-param">cookie-jar</a>
<a class=none href="#basic-authorization">basic-authorization</a>
<a class=none href="#user-agent">user-agent</a>
<a class=none href="#accept">accept</a>
<a class=none href="#range">range</a>
<a class=none href="#proxy">proxy</a>
<a class=none href="#proxy-basic-authorization">proxy-basic-authorization</a>
<a class=none href="#additional-headers">additional-headers</a>
<a class=none href="#redirect">redirect</a>
<a class=none href="#redirect-methods">redirect-methods</a>
<a class=none href="#auto-referer">auto-referer</a>
<a class=none href="#keep-alive">keep-alive</a>
<a class=none href="#close">close</a>
<a class=none href="#external-format-out">external-format-out</a>
<a class=none href="#external-format-in">external-format-in</a>
<a class=none href="#force-binary">force-binary</a>
<a class=none href="#want-stream">want-stream</a>
<a class=none href="#stream">stream</a>
<a class=none href="#preserve-uri">preserve-uri</a>
<a class=none href="#connection-timeout">connection-timeout</a>
<a class=none href="#read-timeout">read-timeout</a>
<a class=none href="#write-timeout">write-timeout</a>
<a class=none href="#deadline">deadline</a></i>
</td>
</tr>
<tr>
<td colspan=2></td>
<td colspan=2 valign=top> => <i>body-or-stream, status-code, headers, uri, stream, <a class=none href="#must-close">must-close</a>, reason-phrase</i></td>
</tr>
</table>
<blockquote><br>
Sends an <a href="http://www.rfc.net/rfc2616.html">HTTP</a> request to a web server and returns its reply.
<a class=none name="uri"><code><i>uri</i></code></a> is where the
request is sent to, and it is either a string denoting
a <a
href="http://en.wikipedia.org/wiki/Uniform_Resource_Identifier">uniform
resource identifier</a> or
a <a href="http://www.cliki.net/Puri"><code>PURI:URI</code></a>
object. The scheme of <code><i>uri</i></code> must be 'http' or
'https'. The function returns <em>seven</em> values - the body of the
reply (but see below), the status code as an integer,
an <a
href="http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_a.htm#alist">alist</a>
of the headers sent by the server where for each element
the <a
href="http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_c.htm#car">car</a>
(the name of the header) is a keyword and
the <a
href="http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_c.htm#cdr">cdr</a>
(the value of the header) is a string, the URI the reply comes from
(which might be different from the URI the request was sent to in case
of <a href="#redirect">redirects</a>), the stream the reply was read
from,
a <a
href="http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_g.htm#generalized_boolean">generalized
boolean</a> which denotes whether the stream should be closed (and
which you can usually ignore), and finally the reason phrase from the
status line as a string.
<p>
<a class=none name="protocol"><code><i>protocol</i></code></a> is the HTTP protocol which is going to be used in the
<a href="http://www.rfc.net/rfc2616.html#s5.1">request line</a>, it must be one of the keywords <code>:HTTP/1.0</code> or
<code>:HTTP/1.1</code> (the default). <a class=none
name="method"><code><i>method</i></code></a> is the method used in the
request line,
a <a
href="http://www.lispworks.com/documentation/HyperSpec/Body/t_kwd.htm">keyword</a>
(like <code>:GET</code> or <code>:HEAD</code>) denoting a
valid <a href="http://rfc.net/rfc2616.html">HTTP/1.1</a>
or <a href="http://www.webdav.org/">WebDAV</a> request method or :REPORT, as described in the Versioning Extensions to WebDAV.
Additionally, you can also use the pseudo method <code>:OPTIONS*</code> which is like
<code>:OPTIONS</code> but means that an "<code>OPTIONS *</code>"
request line will be sent, i.e. the URI's path and query parts will be
ignored.
<p>
If <a class=none
name="force-ssl"><code><i>force-ssl</i></code></a> is true,
<a href="http://en.wikipedia.org/wiki/Secure_Sockets_Layer">SSL</a>
will be <a href="http://www.lispworks.com/documentation/lw50/LWRM/html/lwref-24.htm">attached</a> to the socket stream which connects Drakma with the
web server. Usually, you don't have to provide this argument, as SSL
will be attached anyway if the scheme of <code><i>uri</i></code> is 'https'.
<p>
<a class=none name="certificate"><code><i>certificate</i></code></a>
is the file name of the PEM encoded client certificate to present to
the server when making a SSL connection. <a class=none
name="key"><code><i>key</i></code></a> specifies the file name
of the PEM encoded private key matching the certificate.
<a class=none
name="certificate-password"><code><i>certificate-password</i></code></a>
specifies the pass phrase to use to decrypt the private key.
The <i>certificate</i>, <i>key</i> and <i>certificate-password</i>
parameters are ignored for non-SSL connections.
<p>
<a class=none name="verify"><code><i>verify</i></code></a> can be
specified to force verification of the certificate that is presented
by the server in an SSL connection. It can be specified either
as <i>nil</i> if no check should be performed, <i>:optional</i> to
verify the server's certificate if it presented one
or <i>:required</i> to verify the server's certificate and fail if an
invalid or no certificate was presented.
<p>
<a class=none name="max-depth"><code><i>max-depth</i></code></a> can
be specified to change the maximum allowed certificate signing depth
that is accepted. The default is 10.
<p>
<a class=none name="ca-file"><code><i>ca-file</i></code></a>
and <a class=none
name="ca-directory"><code><i>ca-directory</i></code></a> can be
specified to set the certificate authority bundle file or directory to
use for certificate validation.
<p>
The <i>certificate</i>, <i>key</i>, <i>certificate-password</i>,
<i>verify</i>, <i>max-depth</i>, <i>ca-file</i>
and <i>ca-directory</i> parameters are ignored for non-SSL
requests.
<p>
<a class=none name="parameters"><code><i>parameters</i></code></a> is
an <a
href="http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_a.htm#alist">alist</a>
of name/value pairs
(the <a
href="http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_c.htm#car">car</a>
and
the <a
href="http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_c.htm#cdr">cdr</a>
each being a string) which denotes the parameters which are added to
the query part of the URI or (in the case of a POST request) comprise
the request body. (But
see <a href="#content"><code><i>content</i></code></a> below.)
The values can also be
<code>NIL</code> in which case only the name (without an equal sign) is used in
the query string. The
name/value pairs
are <a
href="http://www.blooberry.com/indexdot/html/topics/urlencoding.htm">URL-encoded</a>
using the external format <a class=none
name="external-format-out"><code><i>external-format-out</i></code></a>
before they are sent to the server, <em>unless</em> <a class=none
name="form-data"><code><i>form-data</i></code></a> is true in which
case the POST request body is sent
as <a
href="http://www.ietf.org/rfc/rfc2388.txt"><code>multipart/form-data</code></a>
using
<code><i>external-format-out</i></code>. The values of
the <code><i>parameters</i></code> alist can also be pathnames, unary
functions, open binary input streams, or lists where the first element
is of one of the former types. These values denote files which should
be sent as part of the request body. If such file designators are
present in <code><i>parameters</i></code>, the content type of the
request is <em>always</em> <code>multipart/form-data</code>. If the
value denoting a file is a list, the part of the list behind the first
element is treated as
a <a
href="http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_p.htm#plist">plist</a>
which can be used to optionally specify a content type (the default is
"application/octet-stream") and/or a filename (the default is the
result of
applying <a
href="http://www.lispworks.com/documentation/HyperSpec/Body/f_namest.htm"><code>FILE-NAMESTRING</code></a>
to the pathname) for the file. So, for example, a full file upload
request could look like this:
<pre>
(http-request "http://www.whatever.com/file_upload/"
:method :post
<font color=orange>;; the following line is only needed if the receiving server doesn't accept
;; chunked transfer encoding (like for example Apache 1.x)</font>
<a class=noborder href="#content-length2">:content-length</a> t
:parameters '(("file1" #p"/tmp/top_secret_stuff.doc" :content-type "application/msword" :filename "upload.doc")
("file2" . #p"/tmp/portrait.jpg")
("lname" . "Duck") ("fname" . "Donald")))
</pre>
<p>
<code><i>external-format-out</i></code> (the default is the value of <a href="#*drakma-default-external-format*"><code>*DRAKMA-DEFAULT-EXTERNAL-FORMAT*</code></a>) must be the name of a <a href="http://weitz.de/flexi-streams/">FLEXI-STREAMS</a> <a href="http://weitz.de/flexi-streams/#external-formats">external
format</a>.
<p><a class=none name="content"><code><i>content</i></code></a>, if not <code>NIL</code>, is
used as the request body - <code><i>parameters</i></code> is ignored
in this case. <code><i>content</i></code> can be a string, a
sequence of octets, a pathname, an open binary input stream, or a
<a
href="http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_f.htm">function
designator</a>. If <code><i>content</i></code> is a sequence, it will
be directly sent to the server (using <code><i>external-format-out</i></code> in the case of strings). If <code><i>content</i></code> is a
pathname, the binary contents of the corresponding file will be sent
to the server. If <code><i>content</i></code> is a stream, everything
that can be read from the stream
until <a
href="http://www.lispworks.com/documentation/HyperSpec/Body/e_end_of.htm">EOF</a>
will be sent to the server. If <code><i>content</i></code> is a
function designator, the corresponding function will be called with
one argument, the stream to the server, to which it should send data.
<p>
Finally, <code><i>content</i></code> can also be the
keyword <code>:CONTINUATION</code> in which
case <a href="#http-request"><code>HTTP-REQUEST</code></a> returns
only one value - a "continuation" function. This function has one
required argument and one optional argument. The first argument will
be interpreted like <code><i>content</i></code> above (but it cannot
be a keyword), i.e. it will be sent to the server according to its
type. If the second argument is true, the continuation function can
be called again to send more content, if it is <code>NIL</code>, the
continuation function returns
what <a href="#http-request"><code>HTTP-REQUEST</code></a> would have
returned. See <a href="#cont">above</a> for an
example on how to use a continuation function and different types of
content.
<p>
If <code><i>content</i></code> is a sequence, Drakma will
use <a
href="http://www.lispworks.com/documentation/HyperSpec/Body/f_length.htm"><code>LENGTH</code></a>
to determine its length and will use the result for the
'Content-Length' header sent to the server. You can overwrite this
with the <a class=none
name="content-length"><code><i>content-length</i></code></a> parameter
(a non-negative integer) which you can also use for the cases where
Drakma can't or won't determine the content length itself. You can
also explicitly provide a <code><i>content-length</i></code> argument
of <code>NIL</code> which will imply that no 'Content-Length' header
will be sent even if Drakma could compute the value. If no
'Content-Length' header is sent, Drakma will
use <a href="http://weitz.de/chunga/">chunked encoding</a> to send the
content body. Note that this will not work with some older web
servers.
<p>
<a class=none name="content-length2">Providing
a</a> <a href="http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_t.htm#true">true</a>
CONTENT-LENGTH argument which is not a non-negative integer means that
Drakma <em>must</em> build the request body in RAM and compute the
content length even if it would have otherwise used chunked encoding,
for example in the case of file uploads.
<p>
<a class=none name="content-type"><code><i>content-type</i></code></a> is the
corresponding 'Content-Type' header to be sent and will be ignored
unless <code><i>content</i></code> is provided as well.
<p>
Note that a
query already contained in <code><i>uri</i></code> will always be sent
with the request line anyway in addition to other parameters sent by
Drakma.
<p>
<a class=none name="cookie-jar-param"><code><i>cookie-jar</i></code></a> is a <a href="#cookie-jar">cookie
jar</a> containing cookies which will potentially be sent to the
server (if the domain matches, if they haven't expired, etc.) - this
cookie jar will be modified according to the 'Set-Cookie' header(s)
sent back by the server.