Annotation of libwww/Library/src/HTAccess.html, revision 2.46
2.9 timbl 1: <HTML>
2: <HEAD>
2.45 frystyk 3: <TITLE>Access manager for libwww</TITLE>
2.19 timbl 4: <NEXTID N="z11">
2.9 timbl 5: </HEAD>
2.5 timbl 6: <BODY>
2.39 frystyk 7:
2.33 frystyk 8: <H1>Access Manager</H1>
2.39 frystyk 9:
2.41 frystyk 10: <PRE>
11: /*
12: ** (c) COPYRIGHT CERN 1994.
13: ** Please first read the full copyright statement in the file COPYRIGH.
14: */
15: </PRE>
16:
2.39 frystyk 17: This module keeps a list of valid protocol (naming scheme) specifiers
18: with associated access code. It allows documents to be loaded given
19: various combinations of parameters. New access protocols may be
20: registered at any time.<P>
21:
22: This module is implemented by <A HREF="HTAccess.c">HTAccess.c</A>, and
23: it is a part of the <A NAME="z10"
2.46 ! frystyk 24: HREF="http://www.w3.org/hypertext/WWW/Library/User/Guide/Guide.html">Library
2.39 frystyk 25: of Common Code</A>. <P>
26:
27: The module contains a lot of stuff but the main topics are:
28:
29: <UL>
2.41 frystyk 30: <LI><A HREF="#Library">Initializing and Terminating the Library</A>
2.46 ! frystyk 31: <LI><A HREF="#log">Logging of requests</A>
2.39 frystyk 32: <LI><A HREF="#Methods">Management of access methods</A>
33: <LI><A HREF="#Addresses">A lot of hard coded addresses</A>
34: <LI><A HREF="#z1">The HTRequest structure</A>
35: <LI><A HREF="#z100">Management of the HTRequest structure</A>
36: <LI><A HREF="#LoadDoc">Functions for loading a document</A>
37: <LI><A HREF="#ClientHelp">Help functions for clients to get started</A>
38: <LI><A HREF="#PostDoc">Functions for posting a document</A>
39: <LI><A HREF="#ProtReg">Access Method Registration</H2></A>
40: </UL>
41:
2.33 frystyk 42:
43: <PRE>
44: #ifndef HTACCESS_H
1.1 timbl 45: #define HTACCESS_H
2.44 roeber 46:
2.16 luotonen 47: #include "HTList.h"
2.39 frystyk 48: #include "HTChunk.h"
2.35 frystyk 49: </PRE>
1.1 timbl 50:
2.46 ! frystyk 51: <H2>Global Flags</H2>
! 52:
! 53: Flags and variables which may be set to control the Library
! 54:
! 55: <H3>Redirections</H3>
! 56:
! 57: The maximum number of redirections is pr. default 10. This prevents
! 58: the library from going into an infinite loop which is kind of nice :-)
! 59:
2.35 frystyk 60: <PRE>
2.46 ! frystyk 61: extern int HTMaxRedirections;
2.33 frystyk 62: </PRE>
1.1 timbl 63:
2.46 ! frystyk 64: <H3>Other Flags</H3>
2.36 frystyk 65:
66: <PRE>
67: extern char * HTClientHost; /* Name or number of telnetting host */
68: extern BOOL HTSecure; /* Disable security holes? */
2.46 ! frystyk 69:
2.36 frystyk 70: extern char * HTImServer; /* If I'm cern_httpd */
71: extern BOOL HTImProxy; /* If I'm cern_httpd as a proxy */
72: </PRE>
73:
2.41 frystyk 74: <A NAME="Library"><H2>Initializing and Terminating the Library</H2></A>
75:
2.46 ! frystyk 76: <IMG SRC="http://www.w3.org/hypertext/WWW/Icons/32x32/warning.gif">
2.41 frystyk 77: These two functions initiates memory and settings for the Library and
78: cleans up memory kept by the Library when about to exit the
79: application. It is highly recommended that they are used!
80:
81: <PRE>
82: extern BOOL HTLibInit NOPARAMS;
83: extern BOOL HTLibTerminate NOPARAMS;
84: </PRE>
85:
2.39 frystyk 86: <A NAME="Methods"><H2>Method Management</H2></A>
2.33 frystyk 87:
2.41 frystyk 88: These are the valid methods, see <A
2.46 ! frystyk 89: HREF="http://www.w3.org/hypertext/WWW/Protocols/HTTP/Methods.html">HTTP
! 90: Methods</A>. <P>
! 91:
! 92: <B>NOTE:</B> the anchor list of allowed methods are not a bitflag, not
! 93: at list.
2.33 frystyk 94:
95: <PRE>
2.16 luotonen 96: typedef enum {
2.46 ! frystyk 97: METHOD_INVALID = 0x0,
! 98: METHOD_GET = 0x1,
! 99: METHOD_HEAD = 0x2,
! 100: METHOD_POST = 0x4,
! 101: METHOD_PUT = 0x8,
! 102: METHOD_DELETE = 0x10,
! 103: METHOD_LINK = 0x20,
! 104: METHOD_UNLINK = 0x40
2.16 luotonen 105: } HTMethod;
2.33 frystyk 106: </PRE>
107:
108: <H3>Get Method Enumeration</H3>
2.16 luotonen 109:
2.33 frystyk 110: Gives the enumeration value of the method as a function of the (char *) name.
2.16 luotonen 111:
2.33 frystyk 112: <PRE>
2.46 ! frystyk 113: extern HTMethod HTMethod_enum PARAMS((CONST char * name));
2.16 luotonen 114: </PRE>
115:
2.33 frystyk 116: <H3>Get Method String</H3>
2.16 luotonen 117:
2.33 frystyk 118: The reverse of <I>HTMethod_enum()</I>
2.16 luotonen 119:
2.33 frystyk 120: <PRE>
2.46 ! frystyk 121: extern CONST char * HTMethod_name PARAMS((HTMethod method));
2.16 luotonen 122: </PRE>
2.33 frystyk 123:
2.35 frystyk 124: <HR>
125: <EM>This section might be move to the Access Authentication Module</EM>
126:
2.36 frystyk 127: <H4>Match Template Against Filename</H4>
2.16 luotonen 128: <PRE>
2.40 frystyk 129: /* extern HTAA_templateMatch()
2.16 luotonen 130: ** STRING COMPARISON FUNCTION FOR FILE NAMES
131: ** WITH ONE WILDCARD * IN THE TEMPLATE
132: ** NOTE:
133: ** This is essentially the same code as in HTRules.c, but it
134: ** cannot be used because it is embedded in between other code.
135: ** (In fact, HTRules.c should use this routine, but then this
136: ** routine would have to be more sophisticated... why is life
137: ** sometimes so hard...)
138: **
139: ** ON ENTRY:
2.37 frystyk 140: ** tmplate is a template string to match the file name
2.16 luotonen 141: ** agaist, may contain a single wildcard
142: ** character * which matches zero or more
143: ** arbitrary characters.
144: ** filename is the filename (or pathname) to be matched
145: ** agaist the template.
146: **
147: ** ON EXIT:
148: ** returns YES, if filename matches the template.
149: ** NO, otherwise.
150: */
2.40 frystyk 151: extern BOOL HTAA_templateMatch PARAMS((CONST char * tmplate,
2.16 luotonen 152: CONST char * filename));
2.35 frystyk 153: </PRE>
154: <HR>
2.16 luotonen 155:
2.46 ! frystyk 156: The following have to be defined in advance of the other include files
2.10 timbl 157: because of circular references.
2.46 ! frystyk 158:
2.33 frystyk 159: <PRE>
160: typedef struct _HTRequest HTRequest;
2.39 frystyk 161: typedef struct _HTNetInfo HTNetInfo;
2.10 timbl 162:
2.14 luotonen 163: /*
2.39 frystyk 164: ** Callback to a protocol module
2.14 luotonen 165: */
2.39 frystyk 166: typedef int (*HTLoadCallBack) PARAMS((HTRequest * req));
2.14 luotonen 167:
2.10 timbl 168: #include "HTAnchor.h"
169: #include <A
170: NAME="z3" HREF="HTFormat.html">"HTFormat.h"</A>
2.15 luotonen 171: #include "HTAAUtil.h" /* HTAAScheme, HTAAFailReason */
2.14 luotonen 172: #include "HTAABrow.h" /* HTAASetup */
2.33 frystyk 173: </PRE>
2.10 timbl 174:
2.46 ! frystyk 175: <A NAME="HeaderMask"><H2>General HTTP Header Mask</H2></A>
! 176:
! 177: This mask enables and disables which automaticly generated HTTP
! 178: headers are to be sent in a request. If the bit is not turned on they
! 179: are not sent. Extra header can be generated when initializing the <A
! 180: HREF="#ExtraHeaders">ExtraHeaders field</A>. The first set is general
! 181: headers and the second is request headers.
! 182:
! 183: <PRE>
! 184: typedef enum _HeaderEnum {
! 185: HT_DATE = 0x1,
! 186: HT_MESSAGE_ID = 0x2,
! 187: HT_MIME = 0x4, /* MIME-Version */
! 188:
! 189: HT_ACCEPT = 0x8,
! 190: HT_FROM = 0x10,
! 191: HT_PRAGMA = 0x20,
! 192: HT_REFERER = 0x40,
! 193: HT_USER_AGENT = 0x80
! 194: } HeaderEnum;
! 195:
! 196: #define <A NAME="DEF_HEAD">DEFAULT_HEADERS</A> HT_ACCEPT+HT_REFERER+HT_USER_AGENT
! 197: </PRE>
! 198:
! 199: <H2>Entity Header Mask</H2>
! 200:
! 201: The entity headers contain information about the object sent in the
! 202: HTTP transaction. See the <A HREF="HTAnchor.html">Anchor module</A>,
! 203: for the storage of entity headers. This flag defines which headers are
! 204: to be sent in a request together with an entity body (the <B>O</B>
! 205: stands for <EM>object</EM>)
! 206:
! 207: <PRE>
! 208: typedef enum _EntityHeaderEnum {
! 209: HT_ALLOW = 0x1,
! 210: HT_CONTENT_ENCODING = 0x2,
! 211: HT_CONTENT_LANGUAGE = 0x4,
! 212: HT_CONTENT_LENGTH = 0x8,
! 213: HT_CTE = 0x10, /* Content-Transfer-Encoding */
! 214: HT_CONTENT_TYPE = 0x20,
! 215: HT_DERIVED_FROM = 0x40,
! 216: HT_EXPIRES = 0x80,
! 217: HT_LAST_MODIFIED = 0x200,
! 218: HT_LINK = 0x400,
! 219: HT_TITLE = 0x800,
! 220: HT_URI = 0x1000,
! 221: HT_VERSION = 0x2000
! 222: } EntityHeaderEnum;
! 223:
! 224: #define <A NAME="DEF_ENTITY">DEFAULT_ENTITY_HEADERS</A> HT_CONTENT_TYPE+HT_CONTENT_LENGTH \
! 225: +HT_DERIVED_FROM+HT_VERSION
! 226: </PRE>
! 227:
2.39 frystyk 228: <A NAME="Addresses"><H2>Default WWW Addresses</H2></A>
2.10 timbl 229:
2.33 frystyk 230: These control the home page selection. To mess with these for normal browses
2.6 timbl 231: is asking for user confusion.
2.33 frystyk 232: <PRE>
233: #define LOGICAL_DEFAULT "WWW_HOME" /* Defined to be the home page */
1.1 timbl 234:
2.6 timbl 235: #ifndef PERSONAL_DEFAULT
2.33 frystyk 236: #define PERSONAL_DEFAULT "WWW/default.html" /* in home directory */
2.6 timbl 237: #endif
2.33 frystyk 238:
2.46 ! frystyk 239: /* If the home page isn't found, use this file: */
! 240: #ifndef LAST_RESORT
! 241: #define LAST_RESORT "http://www.w3.org/"
2.6 timbl 242: #endif
2.33 frystyk 243:
244: /* If one telnets to an access point it will look in this file for home page */
2.7 timbl 245: #ifndef REMOTE_POINTER
2.33 frystyk 246: #define REMOTE_POINTER "/etc/www-remote.url" /* can't be file */
2.7 timbl 247: #endif
2.33 frystyk 248:
2.7 timbl 249: /* and if that fails it will use this. */
2.6 timbl 250: #ifndef REMOTE_ADDRESS
2.46 ! frystyk 251: #define REMOTE_ADDRESS "http://www.w3.org/remote.html" /* can't be file */
1.1 timbl 252: #endif
253:
2.46 ! frystyk 254: /* Default log file name */
1.1 timbl 255: #ifndef DEFAULT_LOGFILE
2.46 ! frystyk 256: #define DEFAULT_LOGFILE "www-log"
1.1 timbl 257: #endif
258:
2.46 ! frystyk 259: #ifndef LOCAL_DEFAULT_FILE
! 260: #define LOCAL_DEFAULT_FILE "/usr/local/lib/WWW/default.html"
1.1 timbl 261: #endif
262:
2.33 frystyk 263: /* This is the default cache directory: */
2.46 ! frystyk 264: #ifndef HT_CACHE_ROOT
! 265: #define HT_CACHE_ROOT "/tmp"
2.23 frystyk 266: #endif
267:
2.33 frystyk 268: /* The default directory for "save locally" and "save and execute" files: */
2.46 ! frystyk 269: #ifndef HT_TMP_ROOT
! 270: #define HT_TMP_ROOT "/tmp"
2.23 frystyk 271: #endif
2.33 frystyk 272: </PRE>
2.10 timbl 273:
2.34 frystyk 274: <H2><A NAME="HTNetInfo">Protocol Specific Information</A></H2>
275:
2.45 frystyk 276: This structure contains information about socket number, input buffer
277: for reading from the network etc. The structure is used through out
278: the protocol modules and is the refenrence point for introducing multi
279: threaded execution into the library, see specifications on <A
2.46 ! frystyk 280: HREF="http://www.w3.org/hypertext/WWW/Library/User/Features/multithread.html">Multiple
2.45 frystyk 281: Threads</A>.
2.34 frystyk 282:
283: <PRE>
2.46 ! frystyk 284: typedef enum _SocAction {
! 285: SOC_INVALID = -1,
! 286: SOC_WRITE = 0, /* By default ready to write */
! 287: SOC_READ,
! 288: SOC_INTERRUPT
! 289: } SocAction;
! 290:
2.39 frystyk 291: struct _HTNetInfo {
2.45 frystyk 292: SOCKFD sockfd; /* Socket descripter */
2.39 frystyk 293: SockA sock_addr; /* SockA is defined in tcp.h */
2.36 frystyk 294: HTInputSocket * isoc; /* Input buffer */
2.46 ! frystyk 295: SocAction action; /* Result of the select call */
! 296: HTStream * target; /* Target stream */
2.36 frystyk 297: int addressCount; /* Attempts if multi-homed host */
2.39 frystyk 298: time_t connecttime; /* Used on multihomed hosts */
2.36 frystyk 299: struct _HTRequest * request; /* Link back to request structure */
2.39 frystyk 300: };
2.34 frystyk 301: </PRE>
302:
2.36 frystyk 303: <EM><B>Note:</B> The AddressCount varaible is used to count the number
304: of attempt to connect to a multi-homed host so we know when to stop
305: trying new IP-addresses.</EM>
306:
2.46 ! frystyk 307: <H2><A NAME="z1">The Request structure</A></H2>
! 308:
! 309: When a request is handled, all kinds of things about it need to be
! 310: passed along. These are all put into a HTRequest structure. This is
! 311: the most essential structure in the library. It contains two main
! 312: categories of information regarding a request:
! 313:
! 314: <UL>
! 315: <LI>Application dependent information
! 316: <LI>Library dependent information
! 317: </UL>
! 318:
! 319: Applications using the Library should <EM>never</EM> use the internal
! 320: library dependent information. It's only because we dont have real
! 321: classes that we can't hide it. <P>
! 322:
! 323: <B>Note:</B> If you reuse the request structure for more than one
! 324: request then make sure that the request is re-initialized, so that no
! 325: `old' data is reused, see <A HREF="#z100">functions to manipulate
! 326: HTRequest Structure</A>. The library handles its own internal
! 327: information from request to request but the information set by the
! 328: caller is untouched. <P>
2.31 frystyk 329:
2.46 ! frystyk 330: The elements of the request structure are as follows:
2.39 frystyk 331:
332: <PRE>
333: struct _HTRequest {
334: </PRE>
2.19 timbl 335:
2.46 ! frystyk 336: <H3>Application Dependent - Set by the caller of HTAccess</H3>
2.19 timbl 337:
2.39 frystyk 338: <PRE>
339: <A HREF="#Methods">HTMethod</A> method;
340: </PRE>
341:
342: An enum used to specify the HTTP <A NAME="z7"
2.46 ! frystyk 343: HREF="../../Protocols/HTTP/Methods.html">method</A> used for the
! 344: actual request. The default value is <A
! 345: HREF="#Methods"><CODE>GET</CODE></A>.
! 346:
! 347: <H4>HTTP Header Information</H4>
2.39 frystyk 348:
349: <PRE>
350: HTList * conversions;
351: </PRE>
352:
2.46 ! frystyk 353: NULL, or a <EM>local</EM> list of specific conversions which the
! 354: format manager can do in order to fulfill the request. It typically
! 355: points to a list set up on initialisation time for example by <A
! 356: HREF="HTInit.html">HTInit()</A>. There is also a <A
! 357: HREF="HTFormat.html#z17"><EM>global</EM></A> list of conversions which
! 358: contains a generic set of possible conversions.
2.39 frystyk 359:
360: <PRE>
361: HTList * encodings;
362: </PRE>
363:
364: The list of encodings acceptable in the output stream.
365:
366: <PRE>
367: HTList * languages;
368: </PRE>
369:
370: The list of (human) language values acceptable in the response. The default
371: is all languages.
372:
373: <PRE>
2.46 ! frystyk 374: HeaderEnum HeaderMask;
! 375: EntityHeaderEnum EntityMask;
! 376: </PRE>
! 377:
! 378: These two masks defines which headers to include in a HTTP request (or
! 379: any other MIME-like protocol). the first mask defines what
! 380: autogenerated HTTP header fields should be sent in the HTTP
! 381: request. The default value is <A
! 382: HREF="DEF_HEAD">DEFAULT_HEADERS</A>. The second defines what entity
! 383: headers should be sent along with an entity (using PUT or POST).
! 384:
! 385: <PRE>
! 386: HTParentAnchor *parentAnchor;
! 387: </PRE>
! 388:
! 389: If this parameter is set then a `Referer: <parent address> can
! 390: be generated in the request to the server, see <A
! 391: HREF="http://www.w3.org/hypertext/WWW/Protocols/HTTP/HTRQ_Headers.html#z14">
! 392: Referer field in a HTTP Request</A>
! 393:
! 394: <PRE>
! 395: <A NAME="#ExtraHeaders">char * ExtraHeaders;</A>
2.39 frystyk 396: </PRE>
397:
2.46 ! frystyk 398: Extra header information can be send along with a request using this
! 399: variable. The text is sent as is so it must be preformatted with
! 400: <CRLF> line terminators.
! 401:
! 402: <H4>Streams From Network to Application</H4>
2.39 frystyk 403:
404: <PRE>
2.46 ! frystyk 405: HTStream * output_stream;
2.39 frystyk 406: </PRE>
407:
2.46 ! frystyk 408: The output stream is to be used to put data down to as they come in
! 409: <B>from</B> the network and back to the application. The default value
! 410: is <CODE>NULL</CODE> which means that the stream goes to the user
! 411: (display).
2.39 frystyk 412:
413: <PRE>
2.46 ! frystyk 414: HTAtom * output_format;
2.39 frystyk 415: </PRE>
416:
2.46 ! frystyk 417: The desired format of the output stream. This can be used to get
! 418: unconverted data etc. from the library. If <CODE>NULL</CODE>, then <A
! 419: HREF="HTFormat.html#FormatTypes">WWW_PRESENT</A> is default value.
2.45 frystyk 420:
421: <PRE>
2.46 ! frystyk 422: HTStream* error_stream;
2.45 frystyk 423: </PRE>
424:
425: All object bodies sent from the server with status codes different
426: from <CODE>200 OK</CODE> will be put down this stream. This can be
427: used as a debug window etc. If the value is NULL (default) then the
428: stream used is <A HREF="HTFormat.html#BlackHole">HTBlackHole</A>.
2.39 frystyk 429:
2.46 ! frystyk 430: <H4>Streams From Application to Network</H4>
! 431:
2.39 frystyk 432: <PRE>
2.46 ! frystyk 433: HTStream * input_stream;
! 434: </PRE>
! 435:
! 436: The input stream is to be used by the <CODE>PostCallBack</CODE>
! 437: function to put data out on the network. The user should not
! 438: initialize this field.
! 439:
! 440: <PRE>
! 441: HTAtom * input_format;
! 442: </PRE>
! 443:
! 444: The desired format of the output stream. This can be used to upload
! 445: converted data to a remote server. If <CODE>NULL</CODE>, then <A
! 446: HREF="HTFormat.html#FormatTypes">WWW_SOURCE</A> is default value.
! 447:
! 448: <PRE>
! 449: int (*PostCallBack) PARAMS((struct _HTRequest * request,
! 450: HTStream * target));
2.39 frystyk 451: </PRE>
452:
2.46 ! frystyk 453: The call back function which is called when the current request is
! 454: ready for sending (posting) the data object. The request is the
! 455: current request so that the application knows which post we are
! 456: handling. The function must have the same return values as the other
! 457: <A HREF="#LoadDoc">Load functions</A>.
! 458:
! 459: <H4>Other Flags</H4>
2.39 frystyk 460:
461: <PRE>
2.43 frystyk 462: BOOL BlockingIO;
2.46 ! frystyk 463: BOOL ForceReload;
2.43 frystyk 464: </PRE>
465:
466: This flag can be set to override if a protocol module is registered as
467: using non-blocking IO.
468:
469: <PRE>
2.46 ! frystyk 470: BOOL (*<A NAME="z9"> callback</A> ) PARAMS((struct _HTRequest* request,
! 471: void *param));
! 472: </PRE>
! 473:
! 474: A function to be called back in the event that a file has been saved
! 475: to disk by HTSaveAndCallBack for example.
! 476:
! 477: <PRE>
! 478: void * context;
2.39 frystyk 479: </PRE>
480:
2.46 ! frystyk 481: An arbitrary pointer passed to HTAccess and passed back as a parameter
! 482: to the <A NAME="z10" HREF="#z9">callback</A>.
2.39 frystyk 483:
2.46 ! frystyk 484: <H3>Library Dependent - Set by Library</H3>
2.39 frystyk 485:
2.46 ! frystyk 486: None of the bits below may be looked at by a WWW application. The
! 487: Library handles the cleanup by itself.
2.39 frystyk 488:
489: <PRE>
490: HTParentAnchor* anchor;
491: </PRE>
492:
493: The anchor for the object in question. Set immediately by HTAcesss.
494: Used by the protocol and parsing modules. Valid thoughout the access.
495:
496: <PRE>
497: HTChildAnchor * childAnchor; /* For element within the object */
498: </PRE>
499:
500: The anchor for the sub object if any. The object builder should
2.46 ! frystyk 501: ensure that is is selected, highlighted, etc when the object is
2.39 frystyk 502: loaded.
503:
504: <PRE>
2.46 ! frystyk 505: struct _HTRequest * CopyRequest;
! 506: </PRE>
! 507:
! 508: We need to know if we have a remote request sending data along with
! 509: this request.
! 510:
! 511: <PRE>
! 512: void * using_cache;
! 513: BOOL using_proxy;
2.39 frystyk 514: </PRE>
515:
2.46 ! frystyk 516: Pointer to cache element if cache hit anfd if using proxy
2.19 timbl 517:
2.25 luotonen 518: <PRE>
2.46 ! frystyk 519: BOOL error_block; /* YES if stream has been used */
! 520: HTList * error_stack; /* List of errors */
! 521: </PRE>
2.25 luotonen 522:
2.46 ! frystyk 523: These two fields are used by the error reporting system to keep a
! 524: stack of messages.
! 525:
! 526: <PRE>
! 527: HTNetInfo * net_info; /* Information about socket etc. */
! 528: int redirections; /* Number of redirections */
2.34 frystyk 529: </PRE>
2.46 ! frystyk 530:
! 531: Protocol specific information, socket number etc.
! 532:
2.34 frystyk 533: <PRE>
2.46 ! frystyk 534: char * redirect; /* Location or URI */
! 535: char * WWWAAScheme; /* WWW-Authenticate scheme */
! 536: char * WWWAARealm; /* WWW-Authenticate realm */
! 537: char * WWWprotection; /* WWW-Protection-Template */
2.25 luotonen 538: </PRE>
2.39 frystyk 539:
2.46 ! frystyk 540: Information taken from the MIME header specifically oriented towards
! 541: the request (not the object itself)
! 542:
2.39 frystyk 543: <PRE>
2.46 ! frystyk 544: char * authorization; /* Authorization: field */
! 545: HTAAScheme scheme; /* Authentication scheme used */
! 546: HTInputSocket * isoc; /* InputSocket object for reading */
! 547: HTAtom * content_type; /* Content-Type: */
! 548: HTAtom * content_language; /* Language */
! 549: HTAtom * content_encoding; /* Encoding */
! 550: int content_length; /* Content-Length: */
2.39 frystyk 551: </PRE>
552:
2.46 ! frystyk 553: These header fields are only used by the server and will be removed at some
! 554: point.
! 555:
2.21 luotonen 556: <PRE>
2.46 ! frystyk 557: HTList * valid_schemes; /* Valid auth.schemes */
! 558: HTAssocList ** scheme_specifics;/* Scheme-specific parameters */
! 559: char * authenticate; /* WWW-authenticate: field */
! 560: char * prot_template; /* WWW-Protection-Template: field */
! 561: HTAASetup * setup; /* Doc protection info */
! 562: HTAARealm * realm; /* Password realm */
! 563: char * dialog_msg; /* Authentication prompt (client) */
2.19 timbl 564: </PRE>
2.46 ! frystyk 565:
! 566: These fields are used by the HTTP access authentication used by a
! 567: client application.
! 568:
2.19 timbl 569: <PRE>
2.10 timbl 570: };
2.31 frystyk 571: </PRE>
572:
573: <H2><A NAME="z100">Functions to Manipulate a HTRequest Structure</A></H2>
574:
575: Just to make things easier especially for clients, here are some functions to
576: manipulate the request structure:
577:
578: <H3>Create blank request</H3>This request has defaults in -- in
2.9 timbl 579: most cases it will need some information
580: added before being passed to HTAccess,
581: but it will work as is for a simple
582: request.
2.14 luotonen 583: <PRE>
2.40 frystyk 584: extern HTRequest * HTRequest_new NOPARAMS;
2.31 frystyk 585: </PRE>
2.14 luotonen 586:
2.31 frystyk 587: <H3>Delete request structure</H3>Frees also conversion list hanging
2.19 timbl 588: from req->conversions.
2.14 luotonen 589: <PRE>
2.40 frystyk 590: extern void HTRequest_delete PARAMS((HTRequest * req));
2.31 frystyk 591: </PRE>
1.1 timbl 592:
2.31 frystyk 593: <H3>Clear a request structure</H3>
2.46 ! frystyk 594:
! 595: Clears a request structure so that it can be reused. The only thing
! 596: that differs from using free/new is that the list of conversions is
! 597: kept. <P>
! 598:
! 599: <B>NOTE:</B> It is <B>NOT</B> recommended to reuse a request structure!!!
! 600:
2.31 frystyk 601: <PRE>
602: extern void HTRequest_clear PARAMS((HTRequest * req));
603: </PRE>
2.9 timbl 604:
2.39 frystyk 605: <A NAME="LoadDoc"><H2>Functions for Loading a Document</H2></A>
606:
607: There are several different ways of loading a document. However, the
608: major difference between them is whether the document is referenced by
609:
610: <UL>
611: <LI><A HREF="#Relative">Relative URI</A>
612: <LI><A HREF="#Absolute">Absolute URI</A>
613: <LI><A HREF="#Anchor">Anchor element</A> or
614: <LI>Contains keywords for <A HREF="#RelSearch">searching an relative URI</A>
615: <LI>Contains keywords for <A HREF="#AbsSearch">searching an absolute URI</A>
616: </UL>
617:
618: <B>NOTE:</B> From release 3.0 of the Library, the return codes from
619: the loading functions are no mode <CODE>BOOL</CODE>, that is
620: <CODE>YES</CODE> or <CODE>NO</CODE>. Insted they have been replaced
621: with the following set of return codes defined in the <A
622: HREF="HTUtils.html#ReturnCodes">Utility module</A>:
623:
2.5 timbl 624: <DL>
2.39 frystyk 625: <DT>HT_WOULD_BLOCK
626: <DD>An I/O operation would block
627:
628: <DT>HT_ERROR
629: <DD>Error has occured
630:
631: <DT>HT_LOADED
632: <DD>Success
633:
634: <DT>HT_NO_DATA
635: <DD>Success, but no document loaded. This might be the situation when a
636: telnet sesssion is started etc.
2.5 timbl 637: </DL>
638:
2.39 frystyk 639: However, a general rule about the return codes is that <B>ERRORS</B>
640: have a <EM>negative</EM> value whereas <B>SUCCESS</B> has a
641: <EM>positive</EM> value. <P>
1.1 timbl 642:
2.39 frystyk 643: There are also some functions to help the client getting started with
644: <A HREF="#ClientHelp">the first URI</A>.
1.1 timbl 645:
2.46 ! frystyk 646: <A NAME="Relative"><H3>Load a document from relative URL</H3></A>
1.1 timbl 647:
2.39 frystyk 648: <PRE>
649: extern int HTLoadRelative PARAMS((CONST char * relative_name,
650: HTParentAnchor* here,
651: HTRequest * request));
2.5 timbl 652: </PRE>
2.39 frystyk 653:
2.46 ! frystyk 654: <A NAME="Absolute"></A><H3>Load a document from absolute URL</H3>
1.1 timbl 655:
2.5 timbl 656: <PRE>
2.39 frystyk 657: extern int HTLoadAbsolute PARAMS((CONST char * addr,
658: HTRequest * request));
2.5 timbl 659: </PRE>
2.39 frystyk 660:
661: <H3>Load a document from absolute name to a stream</H3>
662:
2.5 timbl 663: <PRE>
2.39 frystyk 664: extern int HTLoadToStream PARAMS((CONST char * addr,
665: BOOL filter,
666: HTRequest * request));
2.5 timbl 667: </PRE>
1.1 timbl 668:
2.46 ! frystyk 669: <A NAME="Anchor"><H3>Load a document from anchor</H3></A>
1.1 timbl 670:
2.39 frystyk 671: The anchor parameter may be a child anchor. The anchor in the request
672: is set to the parent anchor. The recursive function keeps the error
673: stack in the request structure so that no information is lost having
674: more than one call. See also <A HREF="#BindAnchor">HTBindAnchor()</A>.
1.1 timbl 675:
2.39 frystyk 676: <PRE>
2.41 frystyk 677: extern int HTLoadAnchor PARAMS((HTAnchor * a,
678: HTRequest * request));
2.39 frystyk 679: extern int HTLoadAnchorRecursive PARAMS((HTAnchor * a,
680: HTRequest * request));
2.5 timbl 681: </PRE>
682:
2.39 frystyk 683: <H3>Load a Document</H3>
684:
2.46 ! frystyk 685: These are two internal routines for loading a document which has an
2.41 frystyk 686: address AND a matching anchor. (The public routines are called with
687: one OR the other.) This is recursively called from file load module
688: to try ftp (though this will be obsolete in the next major
689: release).<P>
1.1 timbl 690:
2.39 frystyk 691: If <CODE>keep_error_stack</CODE> is YES then the error (or info) stack
692: is not cleared from the previous call.
1.1 timbl 693:
2.39 frystyk 694: <PRE>
2.41 frystyk 695: extern int HTLoad PARAMS((HTRequest * request,
696: BOOL keep_error_stack));
697: </PRE>
698:
699: <PRE>
700: extern BOOL HTLoadTerminate PARAMS((HTRequest * request, int status));
2.5 timbl 701: </PRE>
702:
2.46 ! frystyk 703: <A NAME="RelSearch"><H3>Search Using Relative URL</H3></A>
2.39 frystyk 704:
705: Performs a search on word given by the user. Adds the search words to
706: the end of the current address and attempts to open the new address.
707:
2.5 timbl 708: <PRE>
2.39 frystyk 709: extern int HTSearch PARAMS((CONST char * keywords,
710: HTParentAnchor* here,
711: HTRequest * request));
2.5 timbl 712: </PRE>
2.39 frystyk 713:
2.46 ! frystyk 714: <A NAME="AbsSearch"><H3>Search using Absolute URL</H3></A>
2.39 frystyk 715:
716: Performs a keyword search on word given by the user. Adds the keyword
717: to the end of the current address and attempts to open the new
718: address.
2.5 timbl 719:
2.33 frystyk 720: <PRE>
2.40 frystyk 721: extern int HTSearchAbsolute PARAMS((CONST char * keywords,
2.39 frystyk 722: CONST char * indexname,
723: HTRequest * request));
2.5 timbl 724: </PRE>
2.24 luotonen 725:
2.39 frystyk 726:
727: <A NAME="ClientHelp"><H2>Help Function for Clients to get started</H2></A>
728:
729: These function helps the client to load the first document. They are
730: not mandatory to use - but they make life easier!
731:
732: <A NAME="BindAnchor"><H3>Bind an anchor to a request structure without
733: loading</H3></A>
2.24 luotonen 734:
735: <PRE>
2.39 frystyk 736: extern BOOL HTBindAnchor PARAMS((HTAnchor *anchor, HTRequest *request));
2.24 luotonen 737: </PRE>
738:
2.39 frystyk 739: <A NAME="HomePage"><H3>Generate the Anchor for the Home Page</H3></A>
2.24 luotonen 740:
2.39 frystyk 741: As it involves file access, this should only be done once when the
742: program first runs. This is a default algorithm using the
743: <CODE>WWW_HOME</CODE> environment variable.
2.20 frystyk 744:
745: <PRE>
2.40 frystyk 746: extern HTParentAnchor * HTHomeAnchor NOPARAMS;
2.39 frystyk 747: </PRE>
748:
749: <H3>Find Related Name</H3>
750:
751: Creates a local file URI that can be used as a relative name when
752: calling HTParse() to expand a relative file name to an absolute
753: one. <P>
754:
2.46 ! frystyk 755: The code for this routine originates from the Line Mode Browser and
! 756: was moved here by <EM>howcome@dxcern.cern.ch</EM> in order for all
! 757: clients to take advantage.<P>
2.39 frystyk 758:
2.20 frystyk 759: <PRE>
2.39 frystyk 760: extern char * HTFindRelatedName NOPARAMS;
761: </PRE>
762:
763: <A NAME="PostDoc"><H2>Functions for Posting a Document</H2></A>
764:
2.46 ! frystyk 765: <B>NOTE:</B> The Posting functions are used to send a data object
! 766: along with the request. The functions have the same set of return
! 767: codes as for the <A HREF="#LoadDoc">Load Functions</A>.
2.20 frystyk 768:
2.39 frystyk 769: <H3>Get a Save Stream</H3>
2.20 frystyk 770:
2.39 frystyk 771: <H4>On Entry,</H4>
2.5 timbl 772: <DL>
2.9 timbl 773: <DT>request->anchor
774: <DD> is valid anchor which
775: has previously beeing loaded
2.5 timbl 776: </DL>
777:
2.39 frystyk 778: <H4>On exit,</H4>
2.5 timbl 779: <DL>
780: <DT>returns
2.6 timbl 781: <DD> 0 if error else a stream
782: to save the object to.
2.5 timbl 783: </DL>
784:
785: <PRE>
2.46 ! frystyk 786: extern HTStream * HTSaveStream PARAMS((HTRequest * request));
! 787: </PRE>
! 788:
! 789: <H3>Copy an Anchor</H3>
! 790:
! 791: Fetch the URL (possibly local file URL) and send it using either
! 792: <B>PUT</B> or <B>POST</B> directly to the remote destination using
! 793: HTTP, that is remote copy of object <EM>O</EM> from <EM>A</EM> to
! 794: <EM>B</EM> where <EM>A</EM> might be the host of the application. The
! 795: caller can decide the exact method used and which HTTP header fields
! 796: to transmit by setting the user fields in the destination request
! 797: structure.
! 798:
! 799: <PRE>
! 800: extern int HTCopyAnchor PARAMS((HTAnchor * src_anchor,
! 801: HTRequest * src_req,
! 802: HTParentAnchor *dest_anchor,
! 803: HTRequest * dest_req));
! 804: </PRE>
! 805:
! 806:
! 807: <H3>Upload an Anchor</H3>
! 808:
! 809: Send the contents (in hyperdoc) of the source anchor using either
! 810: <B>PUT</B> or <B>POST</B> to the remote destination using HTTP. The
! 811: caller can decide the exact method used and which HTTP header fields
! 812: to transmit by setting the user fields in the request structure.
! 813: <EM>Format conversion</EM> can be made on the fly by setting the <A
! 814: HREF="#input_format">input_format field</A> in the destination request
! 815: structure. If the content-length is unknown (-1) then a <A
! 816: HREF="HTConLen.html">content-length counter</A> is automaticly put
! 817: into the stream pipe.
! 818:
! 819:
! 820: <PRE>
! 821: extern int HTUploadAnchor PARAMS((HTAnchor * src_anchor,
! 822: HTParentAnchor *dest_anchor,
! 823: HTRequest * dest_req));
2.39 frystyk 824: </PRE>
2.5 timbl 825:
1.1 timbl 826:
2.39 frystyk 827: <A NAME="ProtReg"><H2>Access Method Registration</H2></A>
1.1 timbl 828:
2.39 frystyk 829: An access method is defined by an HTProtocol structure which point to
830: the routines for performing the various logical operations on an
831: object: in HTTP terms, GET, PUT, and POST. The access methods
832: supported in the Library are initiated automaticly using the private
833: function <CODE>HTAccessInit()</CODE> <B>if not</B> defined
2.46 ! frystyk 834: <CODE>HT_NO_INIT</CODE> <P>
2.39 frystyk 835:
836: Each of these routine takes as a parameter a <A NAME="z2"
837: HREF="#z1">request structure</A> containing details of the request.
838: When the protocol class routine is called, the anchor element in the
839: request is already valid (made valid by HTAccess).
840:
841: <PRE>
842: typedef enum _HTSocBlock {
843: SOC_BLOCK,
2.42 frystyk 844: SOC_NON_BLOCK
2.39 frystyk 845: } HTSocBlock;
846:
847: typedef struct _HTProtocol {
848: char * name;
849: HTSocBlock block;
850: int (*load) PARAMS((HTRequest * request));
851: HTStream* (*saveStream) PARAMS((HTRequest * request));
852: HTStream* (*postStream) PARAMS((HTRequest * request,
853: HTParentAnchor* postTo));
854: } HTProtocol;
1.1 timbl 855:
2.40 frystyk 856: extern BOOL HTRegisterProtocol PARAMS((HTProtocol * protocol));
2.42 frystyk 857: extern void HTDisposeProtocols NOPARAMS;
2.5 timbl 858: </PRE>
1.1 timbl 859:
2.39 frystyk 860: <H3>Uses Protocol Blocking IO</H3>
1.1 timbl 861:
2.39 frystyk 862: A small function to make life easier. Returns <CODE>YES</CODE> or
2.42 frystyk 863: <CODE>NO</CODE>. If the Library is run in NON-INTERACTIVE MODE then
864: the function always returns YES;
2.38 howcome 865:
866: <PRE>
2.40 frystyk 867: extern BOOL HTProtocolBlocking PARAMS((HTRequest * request));
2.38 howcome 868: </PRE>
869:
2.39 frystyk 870: end
2.25 luotonen 871:
872: <PRE>
1.1 timbl 873: #endif /* HTACCESS_H */
2.25 luotonen 874: </PRE>
875: end of HTAccess
876: </BODY>
2.9 timbl 877: </HTML>
Webmaster