blob: 14244a92fef21d63b898253810343f2188b6dca2 [file] [log] [blame]
Daniel Veillard7c1206f1999-10-14 09:10:25 +00001<HTML
2><HEAD
3><TITLE
4>nanohttp</TITLE
5><META
6NAME="GENERATOR"
7CONTENT="Modular DocBook HTML Stylesheet Version 1.33"><LINK
8REL="HOME"
9TITLE="Gnome XML Library Reference Manual"
10HREF="book1.html"><LINK
11REL="UP"
12TITLE="Gnome XML Library"
13HREF="libxml.html"><LINK
14REL="PREVIOUS"
15TITLE="xmlmemory"
16HREF="gnome-xml-xmlmemory.html"></HEAD
17><BODY
18BGCOLOR="#FFFFFF"
19TEXT="#000000"
20><DIV
21CLASS="NAVHEADER"
22><TABLE
23WIDTH="100%"
24BORDER="0"
25BGCOLOR="#000000"
26CELLPADDING="1"
27CELLSPACING="0"
28><TR
29><TH
30COLSPAN="4"
31ALIGN="center"
32><FONT
33COLOR="#FFFFFF"
34SIZE="5"
35>Gnome XML Library Reference Manual</FONT
36></TH
37></TR
38><TR
39><TD
40WIDTH="25%"
41BGCOLOR="#C00000"
42ALIGN="left"
43><A
44HREF="gnome-xml-xmlmemory.html"
45><FONT
46COLOR="#FFFFFF"
47SIZE="3"
48><B
49>&#60;&#60;&#60; Previous Page</B
50></FONT
51></A
52></TD
53><TD
54WIDTH="25%"
55BGCOLOR="#0000C0"
56ALIGN="center"
57><FONT
58COLOR="#FFFFFF"
59SIZE="3"
60><B
61><A
62HREF="book1.html"
63><FONT
64COLOR="#FFFFFF"
65SIZE="3"
66><B
67>Home</B
68></FONT
69></A
70></B
71></FONT
72></TD
73><TD
74WIDTH="25%"
75BGCOLOR="#00C000"
76ALIGN="center"
77><FONT
78COLOR="#FFFFFF"
79SIZE="3"
80><B
81><A
82HREF="libxml.html"
83><FONT
84COLOR="#FFFFFF"
85SIZE="3"
86><B
87>Up</B
88></FONT
89></A
90></B
91></FONT
92></TD
93><TD
94WIDTH="25%"
95BGCOLOR="#C00000"
96ALIGN="right"
97>&nbsp;</TD
98></TR
99></TABLE
100></DIV
101><H1
102>nanohttp</H1
103><DIV
104CLASS="REFNAMEDIV"
105><A
106NAME="AEN9064"
107></A
108><H2
109>Name</H2
110>nanohttp &#8212; </DIV
111><DIV
112CLASS="REFSYNOPSISDIV"
113><A
114NAME="AEN9067"
115></A
116><H2
117>Synopsis</H2
118><TABLE
119BORDER="0"
120BGCOLOR="#D6E8FF"
121WIDTH="100%"
122CELLPADDING="6"
123><TR
124><TD
125><PRE
126CLASS="SYNOPSIS"
127>&#13;
128
129int <A
130HREF="gnome-xml-nanohttp.html#XMLNANOHTTPFETCH"
131>xmlNanoHTTPFetch</A
132> (const char *URL,
133 const char *filename);
134void* <A
135HREF="gnome-xml-nanohttp.html#XMLNANOHTTPMETHOD"
136>xmlNanoHTTPMethod</A
137> (const char *URL,
138 const char *method,
139 const char *input,
140 char **contentType,
141 const char *headers);
142void* <A
143HREF="gnome-xml-nanohttp.html#XMLNANOHTTPOPEN"
144>xmlNanoHTTPOpen</A
145> (const char *URL,
146 char **contentType);
147int <A
148HREF="gnome-xml-nanohttp.html#XMLNANOHTTPRETURNCODE"
149>xmlNanoHTTPReturnCode</A
150> (void *ctx);
151int <A
152HREF="gnome-xml-nanohttp.html#XMLNANOHTTPREAD"
153>xmlNanoHTTPRead</A
154> (void *ctx,
155 void *dest,
156 int len);
157int <A
158HREF="gnome-xml-nanohttp.html#XMLNANOHTTPSAVE"
159>xmlNanoHTTPSave</A
160> (void *ctxt,
161 const char *filename);
162void <A
163HREF="gnome-xml-nanohttp.html#XMLNANOHTTPCLOSE"
164>xmlNanoHTTPClose</A
165> (void *ctx);</PRE
166></TD
167></TR
168></TABLE
169></DIV
170><DIV
171CLASS="REFSECT1"
172><A
173NAME="AEN9077"
174></A
175><H2
176>Description</H2
177><P
178></P
179></DIV
180><DIV
181CLASS="REFSECT1"
182><A
183NAME="AEN9080"
184></A
185><H2
186>Details</H2
187><DIV
188CLASS="REFSECT2"
189><A
190NAME="AEN9082"
191></A
192><H3
193><A
194NAME="XMLNANOHTTPFETCH"
195></A
196>xmlNanoHTTPFetch ()</H3
197><TABLE
198BORDER="0"
199BGCOLOR="#D6E8FF"
200WIDTH="100%"
201CELLPADDING="6"
202><TR
203><TD
204><PRE
205CLASS="PROGRAMLISTING"
206>int xmlNanoHTTPFetch (const char *URL,
207 const char *filename);</PRE
208></TD
209></TR
210></TABLE
211><P
212>This function try to fetch the indicated resource via HTTP GET
213and save it's content in the file.</P
214><P
215></P
216><DIV
217CLASS="INFORMALTABLE"
218><P
219></P
220><TABLE
221BORDER="0"
222WIDTH="100%"
223BGCOLOR="#FFD0D0"
224CELLSPACING="0"
225CELLPADDING="4"
226CLASS="CALSTABLE"
227><TR
228><TD
229WIDTH="20%"
230ALIGN="RIGHT"
231VALIGN="TOP"
232><TT
233CLASS="PARAMETER"
234><I
235>URL</I
236></TT
237>&nbsp;:</TD
238><TD
239WIDTH="80%"
240ALIGN="LEFT"
241VALIGN="TOP"
242> The URL to load</TD
243></TR
244><TR
245><TD
246WIDTH="20%"
247ALIGN="RIGHT"
248VALIGN="TOP"
249><TT
250CLASS="PARAMETER"
251><I
252>filename</I
253></TT
254>&nbsp;:</TD
255><TD
256WIDTH="80%"
257ALIGN="LEFT"
258VALIGN="TOP"
259> the filename where the content should be saved</TD
260></TR
261><TR
262><TD
263WIDTH="20%"
264ALIGN="RIGHT"
265VALIGN="TOP"
266><I
267CLASS="EMPHASIS"
268>Returns</I
269> :</TD
270><TD
271WIDTH="80%"
272ALIGN="LEFT"
273VALIGN="TOP"
274>-1 in case of failure, 0 incase of success. The contentType,
275if provided must be freed by the caller</TD
276></TR
277></TABLE
278><P
279></P
280></DIV
281></DIV
282><HR><DIV
283CLASS="REFSECT2"
284><A
285NAME="AEN9105"
286></A
287><H3
288><A
289NAME="XMLNANOHTTPMETHOD"
290></A
291>xmlNanoHTTPMethod ()</H3
292><TABLE
293BORDER="0"
294BGCOLOR="#D6E8FF"
295WIDTH="100%"
296CELLPADDING="6"
297><TR
298><TD
299><PRE
300CLASS="PROGRAMLISTING"
301>void* xmlNanoHTTPMethod (const char *URL,
302 const char *method,
303 const char *input,
304 char **contentType,
305 const char *headers);</PRE
306></TD
307></TR
308></TABLE
309><P
310>This function try to open a connection to the indicated resource
311via HTTP using the given <TT
312CLASS="PARAMETER"
313><I
314>method</I
315></TT
316>, adding the given extra headers
317and the input buffer for the request content.</P
318><P
319></P
320><DIV
321CLASS="INFORMALTABLE"
322><P
323></P
324><TABLE
325BORDER="0"
326WIDTH="100%"
327BGCOLOR="#FFD0D0"
328CELLSPACING="0"
329CELLPADDING="4"
330CLASS="CALSTABLE"
331><TR
332><TD
333WIDTH="20%"
334ALIGN="RIGHT"
335VALIGN="TOP"
336><TT
337CLASS="PARAMETER"
338><I
339>URL</I
340></TT
341>&nbsp;:</TD
342><TD
343WIDTH="80%"
344ALIGN="LEFT"
345VALIGN="TOP"
346> The URL to load</TD
347></TR
348><TR
349><TD
350WIDTH="20%"
351ALIGN="RIGHT"
352VALIGN="TOP"
353><TT
354CLASS="PARAMETER"
355><I
356>method</I
357></TT
358>&nbsp;:</TD
359><TD
360WIDTH="80%"
361ALIGN="LEFT"
362VALIGN="TOP"
363> the HTTP method to use</TD
364></TR
365><TR
366><TD
367WIDTH="20%"
368ALIGN="RIGHT"
369VALIGN="TOP"
370><TT
371CLASS="PARAMETER"
372><I
373>input</I
374></TT
375>&nbsp;:</TD
376><TD
377WIDTH="80%"
378ALIGN="LEFT"
379VALIGN="TOP"
380> the input string if any</TD
381></TR
382><TR
383><TD
384WIDTH="20%"
385ALIGN="RIGHT"
386VALIGN="TOP"
387><TT
388CLASS="PARAMETER"
389><I
390>contentType</I
391></TT
392>&nbsp;:</TD
393><TD
394WIDTH="80%"
395ALIGN="LEFT"
396VALIGN="TOP"
397> the Content-Type information IN and OUT</TD
398></TR
399><TR
400><TD
401WIDTH="20%"
402ALIGN="RIGHT"
403VALIGN="TOP"
404><TT
405CLASS="PARAMETER"
406><I
407>headers</I
408></TT
409>&nbsp;:</TD
410><TD
411WIDTH="80%"
412ALIGN="LEFT"
413VALIGN="TOP"
414> the extra headers</TD
415></TR
416></TABLE
417><P
418></P
419></DIV
420></DIV
421><HR><DIV
422CLASS="REFSECT2"
423><A
424NAME="AEN9137"
425></A
426><H3
427><A
428NAME="XMLNANOHTTPOPEN"
429></A
430>xmlNanoHTTPOpen ()</H3
431><TABLE
432BORDER="0"
433BGCOLOR="#D6E8FF"
434WIDTH="100%"
435CELLPADDING="6"
436><TR
437><TD
438><PRE
439CLASS="PROGRAMLISTING"
440>void* xmlNanoHTTPOpen (const char *URL,
441 char **contentType);</PRE
442></TD
443></TR
444></TABLE
445><P
446>This function try to open a connection to the indicated resource
447via HTTP GET.</P
448><P
449></P
450><DIV
451CLASS="INFORMALTABLE"
452><P
453></P
454><TABLE
455BORDER="0"
456WIDTH="100%"
457BGCOLOR="#FFD0D0"
458CELLSPACING="0"
459CELLPADDING="4"
460CLASS="CALSTABLE"
461><TR
462><TD
463WIDTH="20%"
464ALIGN="RIGHT"
465VALIGN="TOP"
466><TT
467CLASS="PARAMETER"
468><I
469>URL</I
470></TT
471>&nbsp;:</TD
472><TD
473WIDTH="80%"
474ALIGN="LEFT"
475VALIGN="TOP"
476> The URL to load</TD
477></TR
478><TR
479><TD
480WIDTH="20%"
481ALIGN="RIGHT"
482VALIGN="TOP"
483><TT
484CLASS="PARAMETER"
485><I
486>contentType</I
487></TT
488>&nbsp;:</TD
489><TD
490WIDTH="80%"
491ALIGN="LEFT"
492VALIGN="TOP"
493> if available the Content-Type information will be
494returned at that location</TD
495></TR
496></TABLE
497><P
498></P
499></DIV
500></DIV
501><HR><DIV
502CLASS="REFSECT2"
503><A
504NAME="AEN9156"
505></A
506><H3
507><A
508NAME="XMLNANOHTTPRETURNCODE"
509></A
510>xmlNanoHTTPReturnCode ()</H3
511><TABLE
512BORDER="0"
513BGCOLOR="#D6E8FF"
514WIDTH="100%"
515CELLPADDING="6"
516><TR
517><TD
518><PRE
519CLASS="PROGRAMLISTING"
520>int xmlNanoHTTPReturnCode (void *ctx);</PRE
521></TD
522></TR
523></TABLE
524><P
525></P
526><P
527></P
528><DIV
529CLASS="INFORMALTABLE"
530><P
531></P
532><TABLE
533BORDER="0"
534WIDTH="100%"
535BGCOLOR="#FFD0D0"
536CELLSPACING="0"
537CELLPADDING="4"
538CLASS="CALSTABLE"
539><TR
540><TD
541WIDTH="20%"
542ALIGN="RIGHT"
543VALIGN="TOP"
544><TT
545CLASS="PARAMETER"
546><I
547>ctx</I
548></TT
549>&nbsp;:</TD
550><TD
551WIDTH="80%"
552ALIGN="LEFT"
553VALIGN="TOP"
554> the HTTP context</TD
555></TR
556><TR
557><TD
558WIDTH="20%"
559ALIGN="RIGHT"
560VALIGN="TOP"
561><I
562CLASS="EMPHASIS"
563>Returns</I
564> :</TD
565><TD
566WIDTH="80%"
567ALIGN="LEFT"
568VALIGN="TOP"
569>the HTTP return code for the request.</TD
570></TR
571></TABLE
572><P
573></P
574></DIV
575></DIV
576><HR><DIV
577CLASS="REFSECT2"
578><A
579NAME="AEN9175"
580></A
581><H3
582><A
583NAME="XMLNANOHTTPREAD"
584></A
585>xmlNanoHTTPRead ()</H3
586><TABLE
587BORDER="0"
588BGCOLOR="#D6E8FF"
589WIDTH="100%"
590CELLPADDING="6"
591><TR
592><TD
593><PRE
594CLASS="PROGRAMLISTING"
595>int xmlNanoHTTPRead (void *ctx,
596 void *dest,
597 int len);</PRE
598></TD
599></TR
600></TABLE
601><P
602>This function tries to read <TT
603CLASS="PARAMETER"
604><I
605>len</I
606></TT
607> bytes from the existing HTTP connection
608and saves them in <TT
609CLASS="PARAMETER"
610><I
611>dest</I
612></TT
613>. This is a blocking call.</P
614><P
615></P
616><DIV
617CLASS="INFORMALTABLE"
618><P
619></P
620><TABLE
621BORDER="0"
622WIDTH="100%"
623BGCOLOR="#FFD0D0"
624CELLSPACING="0"
625CELLPADDING="4"
626CLASS="CALSTABLE"
627><TR
628><TD
629WIDTH="20%"
630ALIGN="RIGHT"
631VALIGN="TOP"
632><TT
633CLASS="PARAMETER"
634><I
635>ctx</I
636></TT
637>&nbsp;:</TD
638><TD
639WIDTH="80%"
640ALIGN="LEFT"
641VALIGN="TOP"
642> the HTTP context</TD
643></TR
644><TR
645><TD
646WIDTH="20%"
647ALIGN="RIGHT"
648VALIGN="TOP"
649><TT
650CLASS="PARAMETER"
651><I
652>dest</I
653></TT
654>&nbsp;:</TD
655><TD
656WIDTH="80%"
657ALIGN="LEFT"
658VALIGN="TOP"
659> a buffer</TD
660></TR
661><TR
662><TD
663WIDTH="20%"
664ALIGN="RIGHT"
665VALIGN="TOP"
666><TT
667CLASS="PARAMETER"
668><I
669>len</I
670></TT
671>&nbsp;:</TD
672><TD
673WIDTH="80%"
674ALIGN="LEFT"
675VALIGN="TOP"
676> the buffer length</TD
677></TR
678><TR
679><TD
680WIDTH="20%"
681ALIGN="RIGHT"
682VALIGN="TOP"
683><I
684CLASS="EMPHASIS"
685>Returns</I
686> :</TD
687><TD
688WIDTH="80%"
689ALIGN="LEFT"
690VALIGN="TOP"
691>the number of byte read. 0 is an indication of an end of connection.
692-1 indicates a parameter error.</TD
693></TR
694></TABLE
695><P
696></P
697></DIV
698></DIV
699><HR><DIV
700CLASS="REFSECT2"
701><A
702NAME="AEN9204"
703></A
704><H3
705><A
706NAME="XMLNANOHTTPSAVE"
707></A
708>xmlNanoHTTPSave ()</H3
709><TABLE
710BORDER="0"
711BGCOLOR="#D6E8FF"
712WIDTH="100%"
713CELLPADDING="6"
714><TR
715><TD
716><PRE
717CLASS="PROGRAMLISTING"
718>int xmlNanoHTTPSave (void *ctxt,
719 const char *filename);</PRE
720></TD
721></TR
722></TABLE
723><P
724>This function saves the output of the HTTP transaction to a file
725It closes and free the context at the end</P
726><P
727></P
728><DIV
729CLASS="INFORMALTABLE"
730><P
731></P
732><TABLE
733BORDER="0"
734WIDTH="100%"
735BGCOLOR="#FFD0D0"
736CELLSPACING="0"
737CELLPADDING="4"
738CLASS="CALSTABLE"
739><TR
740><TD
741WIDTH="20%"
742ALIGN="RIGHT"
743VALIGN="TOP"
744><TT
745CLASS="PARAMETER"
746><I
747>ctxt</I
748></TT
749>&nbsp;:</TD
750><TD
751WIDTH="80%"
752ALIGN="LEFT"
753VALIGN="TOP"
754>&nbsp;</TD
755></TR
756><TR
757><TD
758WIDTH="20%"
759ALIGN="RIGHT"
760VALIGN="TOP"
761><TT
762CLASS="PARAMETER"
763><I
764>filename</I
765></TT
766>&nbsp;:</TD
767><TD
768WIDTH="80%"
769ALIGN="LEFT"
770VALIGN="TOP"
771> the filename where the content should be saved</TD
772></TR
773><TR
774><TD
775WIDTH="20%"
776ALIGN="RIGHT"
777VALIGN="TOP"
778><I
779CLASS="EMPHASIS"
780>Returns</I
781> :</TD
782><TD
783WIDTH="80%"
784ALIGN="LEFT"
785VALIGN="TOP"
786>-1 in case of failure, 0 incase of success.</TD
787></TR
788></TABLE
789><P
790></P
791></DIV
792></DIV
793><HR><DIV
794CLASS="REFSECT2"
795><A
796NAME="AEN9227"
797></A
798><H3
799><A
800NAME="XMLNANOHTTPCLOSE"
801></A
802>xmlNanoHTTPClose ()</H3
803><TABLE
804BORDER="0"
805BGCOLOR="#D6E8FF"
806WIDTH="100%"
807CELLPADDING="6"
808><TR
809><TD
810><PRE
811CLASS="PROGRAMLISTING"
812>void xmlNanoHTTPClose (void *ctx);</PRE
813></TD
814></TR
815></TABLE
816><P
817>This function closes an HTTP context, it ends up the connection and
818free all data related to it.</P
819><P
820></P
821><DIV
822CLASS="INFORMALTABLE"
823><P
824></P
825><TABLE
826BORDER="0"
827WIDTH="100%"
828BGCOLOR="#FFD0D0"
829CELLSPACING="0"
830CELLPADDING="4"
831CLASS="CALSTABLE"
832><TR
833><TD
834WIDTH="20%"
835ALIGN="RIGHT"
836VALIGN="TOP"
837><TT
838CLASS="PARAMETER"
839><I
840>ctx</I
841></TT
842>&nbsp;:</TD
843><TD
844WIDTH="80%"
845ALIGN="LEFT"
846VALIGN="TOP"
847> the HTTP context</TD
848></TR
849></TABLE
850><P
851></P
852></DIV
853></DIV
854></DIV
855><DIV
856CLASS="NAVFOOTER"
857><BR
858CLEAR="all"><BR><TABLE
859WIDTH="100%"
860BORDER="0"
861BGCOLOR="#000000"
862CELLPADDING="1"
863CELLSPACING="0"
864><TR
865><TD
866WIDTH="25%"
867BGCOLOR="#C00000"
868ALIGN="left"
869><A
870HREF="gnome-xml-xmlmemory.html"
871><FONT
872COLOR="#FFFFFF"
873SIZE="3"
874><B
875>&#60;&#60;&#60; Previous Page</B
876></FONT
877></A
878></TD
879><TD
880WIDTH="25%"
881BGCOLOR="#0000C0"
882ALIGN="center"
883><FONT
884COLOR="#FFFFFF"
885SIZE="3"
886><B
887><A
888HREF="book1.html"
889><FONT
890COLOR="#FFFFFF"
891SIZE="3"
892><B
893>Home</B
894></FONT
895></A
896></B
897></FONT
898></TD
899><TD
900WIDTH="25%"
901BGCOLOR="#00C000"
902ALIGN="center"
903><FONT
904COLOR="#FFFFFF"
905SIZE="3"
906><B
907><A
908HREF="libxml.html"
909><FONT
910COLOR="#FFFFFF"
911SIZE="3"
912><B
913>Up</B
914></FONT
915></A
916></B
917></FONT
918></TD
919><TD
920WIDTH="25%"
921BGCOLOR="#C00000"
922ALIGN="right"
923>&nbsp;</TD
924></TR
925><TR
926><TD
927COLSPAN="2"
928ALIGN="left"
929><FONT
930COLOR="#FFFFFF"
931SIZE="3"
932><B
933>xmlmemory</B
934></FONT
935></TD
936><TD
937COLSPAN="2"
938ALIGN="right"
939>&nbsp;</TD
940></TR
941></TABLE
942></DIV
943></BODY
944></HTML
945>