home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 March B / SCO_CASTOR4RRT.iso / nsfast / root.9 / usr / ns-home / nsapi / include / frame / req.h / req
Text File  |  1998-08-19  |  5KB  |  191 lines

  1. /*
  2.  * Copyright (c) 1994, 1995.  Netscape Communications Corporation.  All
  3.  * rights reserved.
  4.  * 
  5.  * Use of this software is governed by the terms of the license agreement for
  6.  * the Netscape FastTrack or Netscape Enterprise Server between the
  7.  * parties.
  8.  */
  9.  
  10.  
  11. /* ------------------------------------------------------------------------ */
  12.  
  13.  
  14. /*
  15.  * req.h: Request-specific data structures and functions
  16.  * 
  17.  * Rob McCool
  18.  */
  19.  
  20.  
  21. #ifndef REQ_H
  22. #define REQ_H
  23.  
  24.  
  25. #include "netsite.h"
  26. #include "base/pblock.h"
  27. #include "base/session.h"
  28. #include "frame/objset.h"
  29.  
  30. #ifndef XP_UNIX
  31. #include <sys/types.h>
  32. #endif /* XP_UNIX */
  33.  
  34. #include "base/file.h"   /* struct stat */
  35.  
  36.  
  37.  
  38. /* ------------------------------ Constants ------------------------------- */
  39.  
  40.  
  41. #define REQ_HASHSIZE 10
  42. #define REQ_MAX_LINE 4096
  43.  
  44.     
  45. /*
  46.  * The REQ_ return codes. These codes are used to determine what the server
  47.  * should do after a particular module completes its task.
  48.  *
  49.  * Func type functions return these as do many internal functions.
  50.  */
  51.  
  52. /* The function performed its task, proceed with the request */
  53. #define REQ_PROCEED 0
  54. /* The entire request should be aborted: An error occurred */
  55. #define REQ_ABORTED -1
  56. /* The function performed no task, but proceed anyway. */
  57. #define REQ_NOACTION -2
  58. /* Tear down the session and exit */
  59. #define REQ_EXIT -3
  60. /* Restart the entire request-response process */
  61. #define REQ_RESTART -4
  62.  
  63.  
  64. /* ------------------------------ Structures ------------------------------ */
  65.  
  66.  
  67. typedef struct {
  68.     /* Server working variables */
  69.     pblock *vars;
  70.  
  71.     /* The method, URI, and protocol revision of this request */
  72.     pblock *reqpb;
  73.     /* Protocol specific headers */
  74.     int loadhdrs;
  75.     pblock *headers;
  76.  
  77.     /* Server's response headers */
  78.     int senthdrs;
  79.     pblock *srvhdrs;
  80.  
  81.     /* The object set constructed to fulfill this request */
  82.     httpd_objset *os;
  83.     /* Array of objects that were created from .nsconfig files */
  84.     httpd_objset *tmpos;
  85.  
  86.     /* The stat last returned by request_stat_path */
  87.     char *statpath;
  88.     char *staterr;
  89.     struct stat *finfo;
  90.  
  91.     /* access control state */
  92.     int aclstate;        /* ACL decision state */
  93.     int acldirno;        /* deciding ACL directive number */
  94.     char * aclname;        /* name of deciding ACL */
  95.     pblock * aclpb;        /* parameter block for ACL PathCheck */
  96.  
  97. #ifdef MCC_PROXY
  98.     struct hostent *hp;    /* proxy NSAPI: DNS resolution result */
  99.     char * host;    /* proxy NSAPI: host to resolve/connect to */
  100.     int    port;    /* proxy NSAPI: port to connect to */
  101.  
  102.     void * socks_rq;    /* SOCKS request data */
  103. #endif
  104.  
  105.     int request_is_cacheable;  /* default TRUE */
  106.     int directive_is_cacheable; /* default FALSE */
  107.  
  108.     char *cached_headers;
  109.     int cached_headers_len;    /* length of the valid headers */
  110.     char *cached_date_header;
  111. } Request;
  112.  
  113.  
  114. /* ------------------------------ Prototypes ------------------------------ */
  115.  
  116.  
  117. /*
  118.  * request_create creates a new request structure.
  119.  */
  120.  
  121. NSAPI_PUBLIC Request *request_create(void);
  122.  
  123. /*
  124.  * request_free destroys a request structure.
  125.  */
  126.  
  127. NSAPI_PUBLIC void request_free(Request *req);
  128.  
  129.  
  130. /*
  131.  * Restarts a request for a given URI internally. If rq is non-NULL, the
  132.  * function will keep the old request's headers and protocol, but with a new 
  133.  * URI and method of GET. If the previous method was HEAD, this is preserved.
  134.  * Any other method becomes GET. You may assume that if you give it a request
  135.  * structure that it will use the same structure.
  136.  *
  137.  * Once you have this new Request, you must then do what you want with
  138.  * it (e.g. send the object back, perform uri2path translation, etc.)
  139.  */
  140.  
  141. NSAPI_PUBLIC Request *request_restart_internal(char *uri, Request *rq);
  142.  
  143.  
  144. /*
  145.  * request_header finds the named header depending on the requesting 
  146.  * protocol. If possible, it will not load headers until the first is 
  147.  * requested. You have to watch out because this can return REQ_ABORTED.
  148.  */
  149.  
  150. NSAPI_PUBLIC int request_header(char *name, char **value, 
  151.                                 Session *sn, Request *rq);
  152.  
  153. /*
  154.  * request_loadheaders just makes sure the headers have been loaded.
  155.  */
  156.  
  157. #define request_loadheaders(sn,rq) (int)(REQ_PROCEED)
  158.  
  159.  
  160. /*
  161.  * request_stat_path tries to stat path. If path is NULL, it will look in
  162.  * the vars pblock for "path". If the stat is successful, it returns the stat 
  163.  * structure. If not, returns NULL and leaves a message in rq->staterr. If a 
  164.  * previous call to this function was successful, and path is the same, the 
  165.  * function will simply return the previously found value.
  166.  *
  167.  * User functions should not free this structure.
  168.  */
  169.  
  170. NSAPI_PUBLIC struct stat *request_stat_path(char *path, Request *rq);
  171.  
  172.  
  173. /*
  174.  * request_handle handles one request from the session's inbuf.
  175.  */
  176.  
  177. NSAPI_PUBLIC void request_handle(Session *sn);
  178.  
  179.  
  180. /* XXXrobm temporary compatibility */
  181. #define request_uri2path servact_uri2path
  182. #define request_pathchecks servact_pathchecks
  183. #define request_fileinfo servact_fileinfo
  184. #define request_service servact_service
  185.  
  186. #define request_handle_processed servact_handle_processed
  187. #define request_translate_uri servact_translate_uri
  188. #define request_finderror servact_finderror
  189.  
  190. #endif
  191.