Annotation of libwww/Library/src/HTReqMan.c, revision 2.75

2.1       frystyk     1: /*                                                                  HTReqMan.c
                      2: **     REQUEST MANAGER
                      3: **
                      4: **     (c) COPYRIGHT MIT 1995.
                      5: **     Please first read the full copyright statement in the file COPYRIGH.
2.75    ! frystyk     6: **     @(#) $Id: HTReqMan.c,v 2.74 1998/12/15 05:34:28 frystyk Exp $
2.1       frystyk     7: **
                      8: ** Authors
                      9: **     TBL     Tim Berners-Lee timbl@w3.org
                     10: **     JFG     Jean-Francois Groff jfg@dxcern.cern.ch
                     11: **     DD      Denis DeLaRoca (310) 825-4580  <CSP1DWD@mvs.oac.ucla.edu>
                     12: **     HFN     Henrik Frystyk, frystyk@w3.org
                     13: ** History
                     14: **       8 Jun 92 Telnet hopping prohibited as telnet is not secure TBL
                     15: **     26 Jun 92 When over DECnet, suppressed FTP, Gopher and News. JFG
                     16: **      6 Oct 92 Moved HTClientHost and HTlogfile into here. TBL
                     17: **     17 Dec 92 Tn3270 added, bug fix. DD
                     18: **      4 Feb 93 Access registration, Search escapes bad chars TBL
                     19: **               PARAMETERS TO HTSEARCH AND HTLOADRELATIVE CHANGED
                     20: **     28 May 93 WAIS gateway explicit if no WAIS library linked in.
                     21: **        Dec 93 Bug change around, more reentrant, etc
                     22: **     09 May 94 logfile renamed to HTlogfile to avoid clash with WAIS
                     23: **      8 Jul 94 Insulate free() from _free structure element.
                     24: **     02 Sep 95 Rewritten and spawned from HTAccess.c, HFN
                     25: */
                     26: 
                     27: #if !defined(HT_DIRECT_WAIS) && !defined(HT_DEFAULT_WAIS_GATEWAY)
                     28: #define HT_DEFAULT_WAIS_GATEWAY "http://www.w3.org:8001/"
                     29: #endif
                     30: 
                     31: /* Library include files */
2.67      frystyk    32: #include "wwwsys.h"
2.40      frystyk    33: #include "WWWUtil.h"
2.1       frystyk    34: #include "HTParse.h"
                     35: #include "HTAlert.h"
                     36: #include "HTError.h"
2.2       frystyk    37: #include "HTNetMan.h"
2.39      frystyk    38: #include "HTEvent.h"
2.1       frystyk    39: #include "HTProt.h"
2.43      eric       40: #include "HTHeader.h"
2.46      frystyk    41: #include "HTLib.h"
2.1       frystyk    42: #include "HTReqMan.h"                                   /* Implemented here */
                     43: 
                     44: #ifndef HT_MAX_RELOADS
                     45: #define HT_MAX_RELOADS 6
                     46: #endif
2.13      frystyk    47: 
2.1       frystyk    48: PRIVATE int HTMaxRetry = HT_MAX_RELOADS;
                     49: 
                     50: struct _HTStream {
                     51:        HTStreamClass * isa;
                     52:        /* ... */
                     53: };
                     54: 
                     55: /* --------------------------------------------------------------------------*/
2.59      frystyk    56: /*                     Create and delete the HTRequest Object               */
2.1       frystyk    57: /* --------------------------------------------------------------------------*/
                     58: 
2.3       frystyk    59: PUBLIC HTRequest * HTRequest_new (void)
2.1       frystyk    60: {
2.29      frystyk    61:     HTRequest * me;
                     62:     if ((me = (HTRequest *) HT_CALLOC(1, sizeof(HTRequest))) == NULL)
                     63:         HT_OUTOFMEM("HTRequest_new()");
2.1       frystyk    64:     
2.7       frystyk    65:    /* Force Reload */
2.56      frystyk    66:     me->reload = HT_CACHE_OK;
2.1       frystyk    67: 
2.40      frystyk    68:     /* Set the default user profile */
                     69:     me->userprofile = HTLib_userProfile();
                     70: 
2.1       frystyk    71:     /* Format of output */
                     72:     me->output_format  = WWW_PRESENT;      /* default it to present to user */
2.21      frystyk    73:     me->debug_format   = WWW_DEBUG;     /* default format of error messages */
2.1       frystyk    74: 
                     75:     /* HTTP headers */
                     76:     me->GenMask                = DEFAULT_GENERAL_HEADERS;
                     77:     me->RequestMask    = DEFAULT_REQUEST_HEADERS;
2.22      frystyk    78:     me->ResponseMask   = DEFAULT_RESPONSE_HEADERS;
2.1       frystyk    79:     me->EntityMask     = DEFAULT_ENTITY_HEADERS;
                     80: 
                     81:     /* Default retry after value */
2.19      frystyk    82:     me->priority = HT_PRIORITY_MAX;
2.1       frystyk    83: 
2.54      frystyk    84:     /* Default max forward value */
                     85:     me->max_forwards = -1;
                     86: 
2.1       frystyk    87:     /* Content negotiation */
2.45      frystyk    88:     me->ContentNegotiation = YES;                     /* Do this by default */
2.1       frystyk    89: 
2.47      frystyk    90:     if (CORE_TRACE) HTTrace("Request..... Created %p\n", me);
                     91: 
2.1       frystyk    92:     return me;
                     93: }
                     94: 
2.28      frystyk    95: /*     HTRequest_clear
                     96: **     ---------------
                     97: **     Clears all protocol specific information so that the request object
                     98: **     can be used for another request.
                     99: **     Returns YES if OK, else NO
                    100: */
                    101: PUBLIC BOOL HTRequest_clear (HTRequest * me)
                    102: {
                    103:     if (me) {
                    104:        me->error_stack = NULL;
                    105:        me->net = NULL;
2.49      frystyk   106:        me->realm = NULL;
2.31      frystyk   107:        me->credentials = NULL;
2.47      frystyk   108:        me->connected = NO;
2.59      frystyk   109:        if (me->response) {
                    110:            HTResponse_delete(me->response);
                    111:            me->response = NULL;
                    112:        }
2.28      frystyk   113:        return YES;
                    114:     }
                    115:     return NO;
                    116: }
                    117: 
2.18      frystyk   118: /*     HTRequest_dup
                    119: **     -------------
                    120: **     Creates a new HTRequest object as a duplicate of the src request.
                    121: **     Returns YES if OK, else NO
                    122: */
                    123: PUBLIC HTRequest * HTRequest_dup (HTRequest * src)
                    124: {
                    125:     HTRequest * me;
2.47      frystyk   126:     if (!src) return NULL;
2.29      frystyk   127:     if ((me = (HTRequest  *) HT_MALLOC(sizeof(HTRequest))) == NULL)
                    128:         HT_OUTOFMEM("HTRequest_dup");
2.18      frystyk   129:     memcpy(me, src, sizeof(HTRequest));
2.47      frystyk   130:     if (CORE_TRACE) HTTrace("Request..... Duplicated %p to %p\n", src, me);
2.18      frystyk   131:     return me;
                    132: }
2.1       frystyk   133: 
2.23      frystyk   134: /*     HTRequest_dupInternal
                    135: **     ---------------------
                    136: **     Creates a new HTRequest object as a duplicate of the src request.
                    137: **     The difference to the HTRequest_dup function is that we don't copy the
                    138: **     error_stack and other information that the application keeps in its
                    139: **     copy of the request object. Otherwise it will be freed multiple times
                    140: **     Returns YES if OK, else NO
                    141: */
                    142: PUBLIC HTRequest * HTRequest_dupInternal (HTRequest * src)
                    143: {
                    144:     HTRequest * me;
2.33      eric      145:     if (!src) return 0;
2.29      frystyk   146:     if ((me = (HTRequest  *) HT_MALLOC(sizeof(HTRequest))) == NULL)
                    147:         HT_OUTOFMEM("HTRequest_dup");
2.23      frystyk   148:     memcpy(me, src, sizeof(HTRequest));
2.28      frystyk   149:     HTRequest_clear(me);
2.23      frystyk   150:     return me;
                    151: }
                    152: 
2.59      frystyk   153: PUBLIC void HTRequest_delete (HTRequest * me)
2.1       frystyk   154: {
2.59      frystyk   155:     if (me) {
                    156:        if (CORE_TRACE) HTTrace("Request..... Delete %p\n", me);
                    157:        if (me->net) HTNet_setRequest(me->net, NULL);
2.47      frystyk   158: 
                    159:        /* Should we delete the output stream? */
2.59      frystyk   160:        if (!me->connected && me->output_stream) {
2.47      frystyk   161:            if (CORE_TRACE)
                    162:                HTTrace("Request..... Deleting dangling output stream\n");
2.59      frystyk   163:            (*me->output_stream->isa->_free)(me->output_stream);
                    164:            me->output_stream = NULL;
2.47      frystyk   165:        }
                    166: 
                    167:        /* Clean up the error stack */
2.59      frystyk   168:        if (me->error_stack) HTError_deleteAll(me->error_stack);
2.13      frystyk   169: 
2.51      frystyk   170:        /* Before and After Filters */
2.65      frystyk   171:        if (me->afters) HTNetCall_deleteAfterAll(me->afters);
                    172:        if (me->befores) HTNetCall_deleteBeforeAll(me->befores);
2.51      frystyk   173: 
2.49      frystyk   174:        /* Access Authentication */
2.59      frystyk   175:        HT_FREE(me->realm);
                    176:        if (me->credentials) HTAssocList_delete(me->credentials);
2.49      frystyk   177: 
2.56      frystyk   178:        /* Cache control headers */
2.59      frystyk   179:        if (me->cache_control)
                    180:            HTAssocList_delete(me->cache_control);
2.57      frystyk   181: 
2.59      frystyk   182:        /* Byte ranges */
                    183:        if (me->byte_ranges) HTAssocList_delete(me->byte_ranges);
2.56      frystyk   184: 
                    185:        /* Connection headers */
2.59      frystyk   186:        if (me->connection) HTAssocList_delete(me->connection);
2.56      frystyk   187: 
2.64      frystyk   188:        /* Connection headers */
                    189:        if (me->expect) HTAssocList_delete(me->expect);
                    190: 
2.53      frystyk   191:        /* Proxy information */
2.59      frystyk   192:        HT_FREE(me->proxy);
2.53      frystyk   193: 
2.49      frystyk   194:        /* PEP Information */
2.59      frystyk   195:        if (me->protocol) HTAssocList_delete(me->protocol);
                    196:        if (me->protocol_request) HTAssocList_delete(me->protocol_request);
                    197:        if (me->protocol_info) HTAssocList_delete(me->protocol_info);
2.49      frystyk   198: 
2.59      frystyk   199:        /* Any response object */
                    200:        if (me->response) HTResponse_delete(me->response);
2.55      frystyk   201: 
2.59      frystyk   202:        HT_FREE(me);
2.1       frystyk   203:     }
                    204: }
                    205: 
                    206: /*
2.59      frystyk   207: **     Kill this request
2.1       frystyk   208: */
2.59      frystyk   209: PUBLIC BOOL HTRequest_kill(HTRequest * me)
2.1       frystyk   210: {
2.59      frystyk   211:     return me ? HTNet_kill(me->net) : NO;
2.1       frystyk   212: }
                    213: 
2.59      frystyk   214: /* --------------------------------------------------------------------------*/
                    215: /*                     Methods on the HTRequest Object                      */
                    216: /* --------------------------------------------------------------------------*/
2.1       frystyk   217: 
                    218: /*
2.59      frystyk   219: **  Internal request object
2.1       frystyk   220: */
2.59      frystyk   221: PUBLIC BOOL HTRequest_setInternal (HTRequest * me, BOOL mode)
2.1       frystyk   222: {
2.59      frystyk   223:     if (me) {
                    224:        me->internal = mode;
                    225:        return YES;
                    226:     }
                    227:     return NO;
2.1       frystyk   228: }
                    229: 
2.59      frystyk   230: PUBLIC BOOL HTRequest_internal (HTRequest * me)
2.1       frystyk   231: {
2.59      frystyk   232:     return (me ? me->internal : NO);
2.62      frystyk   233: }
                    234: 
                    235: /*
                    236: **  Should we flush immediately?
                    237: */
                    238: PUBLIC BOOL HTRequest_setFlush (HTRequest * me, BOOL mode)
                    239: {
                    240:     if (me) {
                    241:        me->flush = mode;
                    242:        return YES;
                    243:     }
                    244:     return NO;
                    245: }
                    246: 
                    247: PUBLIC BOOL HTRequest_flush (HTRequest * me)
                    248: {
                    249:     return (me ? me->flush : NO);
2.1       frystyk   250: }
                    251: 
                    252: /*
2.59      frystyk   253: **     Date/time stamp when then request was issued
                    254: **     This is normally set when generating the request headers.
2.1       frystyk   255: */
2.59      frystyk   256: PUBLIC time_t HTRequest_date (HTRequest * me)
2.1       frystyk   257: {
2.59      frystyk   258:     return me ? me->date : -1;
2.1       frystyk   259: }
                    260: 
2.59      frystyk   261: PUBLIC BOOL HTRequest_setDate (HTRequest * me, time_t date)
2.1       frystyk   262: {
2.59      frystyk   263:     if (me) {
                    264:        me->date = date;
                    265:        return YES;
2.1       frystyk   266:     }
2.59      frystyk   267:     return NO;
2.1       frystyk   268: }
                    269: 
2.37      frystyk   270: /*
2.59      frystyk   271: **     Method
2.37      frystyk   272: */
2.59      frystyk   273: PUBLIC void HTRequest_setMethod (HTRequest * me, HTMethod method)
2.37      frystyk   274: {
2.59      frystyk   275:     if (me) me->method = method;
2.37      frystyk   276: }
                    277: 
2.59      frystyk   278: PUBLIC HTMethod HTRequest_method (HTRequest * me)
2.37      frystyk   279: {
2.59      frystyk   280:     return me ? me->method : METHOD_INVALID;
2.37      frystyk   281: }
                    282: 
2.1       frystyk   283: /*
2.59      frystyk   284: **  Priority to be inherited by all HTNet object hanging off this request
                    285: **  The priority can later be chaned by calling the HTNet object directly
2.1       frystyk   286: */
2.59      frystyk   287: PUBLIC BOOL HTRequest_setPriority (HTRequest * me, HTPriority priority)
2.1       frystyk   288: {
2.59      frystyk   289:     if (me) {
                    290:        me->priority = priority;
                    291:        return YES;
2.1       frystyk   292:     }
2.59      frystyk   293:     return NO;
2.1       frystyk   294: }
                    295: 
2.59      frystyk   296: PUBLIC HTPriority HTRequest_priority (HTRequest * me)
2.1       frystyk   297: {
2.59      frystyk   298:     return (me ? me->priority : HT_PRIORITY_INV);
2.1       frystyk   299: }
                    300: 
                    301: /*
2.59      frystyk   302: **     User Profile
2.1       frystyk   303: */
2.59      frystyk   304: PUBLIC BOOL HTRequest_setUserProfile (HTRequest * me, HTUserProfile * up)
2.1       frystyk   305: {
2.59      frystyk   306:     if (me) {
                    307:        me->userprofile = up;
                    308:        return YES;
2.1       frystyk   309:     }
2.59      frystyk   310:     return NO;
2.1       frystyk   311: }
                    312: 
2.59      frystyk   313: PUBLIC HTUserProfile * HTRequest_userProfile (HTRequest * me)
2.1       frystyk   314: {
2.59      frystyk   315:     return me ? me->userprofile : NULL;
2.1       frystyk   316: }
                    317: 
                    318: /*
2.59      frystyk   319: **     Net Object
2.9       frystyk   320: */
2.59      frystyk   321: PUBLIC BOOL HTRequest_setNet (HTRequest * me, HTNet * net)
2.9       frystyk   322: {
2.59      frystyk   323:     if (me) {
                    324:        me->net = net;
                    325:        return YES;
2.9       frystyk   326:     }
2.59      frystyk   327:     return NO;
2.9       frystyk   328: }
                    329: 
2.59      frystyk   330: PUBLIC HTNet * HTRequest_net (HTRequest * me)
2.9       frystyk   331: {
2.59      frystyk   332:     return me ? me->net : NULL;
2.9       frystyk   333: }
                    334: 
                    335: /*
2.59      frystyk   336: **     Response Object. If the object does not exist then create it at the
                    337: **     same time it is asked for.
2.9       frystyk   338: */
2.59      frystyk   339: PUBLIC HTResponse * HTRequest_response (HTRequest * me)
2.9       frystyk   340: {
2.43      eric      341:     if (me) {
2.59      frystyk   342:        if (!me->response)
                    343:            me->response = HTResponse_new();
                    344:        return me->response;
2.9       frystyk   345:     }
2.59      frystyk   346:     return NULL;
2.9       frystyk   347: }
                    348: 
2.59      frystyk   349: PUBLIC BOOL HTRequest_setResponse (HTRequest * me, HTResponse * response)
2.9       frystyk   350: {
2.43      eric      351:     if (me) {
2.75    ! frystyk   352:        if (me->response) HTResponse_delete(me->response);
2.59      frystyk   353:        me->response = response;
                    354:        return YES;
2.9       frystyk   355:     }
2.59      frystyk   356:     return NO;
2.43      eric      357: }
                    358: 
2.59      frystyk   359: /*     Error Management
                    360: **     ----------------
                    361: **     Returns the error stack if a stream is 
2.1       frystyk   362: */
2.59      frystyk   363: PUBLIC HTList * HTRequest_error (HTRequest * me)
2.1       frystyk   364: {
2.59      frystyk   365:     return me ? me->error_stack : NULL;
2.1       frystyk   366: }
                    367: 
2.59      frystyk   368: PUBLIC void HTRequest_setError (HTRequest * me, HTList * list)
2.1       frystyk   369: {
2.59      frystyk   370:     if (me) me->error_stack = list;
2.1       frystyk   371: }
2.66      frystyk   372: 
                    373: /* begin _GM_ */
                    374: /* Note: libwww bug ID: GM11 */
                    375: PUBLIC void HTRequest_deleteAllErrors (HTRequest * request)
                    376: {
                    377:     HTError_deleteAll(request->error_stack);
                    378:     HTRequest_setError(request, NULL);
                    379: }
                    380: /* end _GM_ */
2.1       frystyk   381: 
2.59      frystyk   382: PUBLIC BOOL HTRequest_addError (HTRequest *    me,
                    383:                                HTSeverity      severity,
                    384:                                BOOL            ignore,
                    385:                                int             element,
                    386:                                void *          par,
                    387:                                unsigned int    length,
                    388:                                char *          where)
2.1       frystyk   389: {
2.59      frystyk   390:     if (me) {
                    391:        if (!me->error_stack) me->error_stack = HTList_new();
                    392:        return HTError_add(me->error_stack, severity, ignore, element,
                    393:                           par, length, where);
                    394:     }
                    395:     return NO;
2.1       frystyk   396: }
                    397: 
2.59      frystyk   398: PUBLIC BOOL HTRequest_addSystemError (HTRequest *      me,
                    399:                                      HTSeverity        severity,
                    400:                                      int               errornumber,
                    401:                                      BOOL              ignore,
                    402:                                      char *            syscall)
2.1       frystyk   403: {
2.59      frystyk   404:     if (me) {
                    405:        if (!me->error_stack) me->error_stack = HTList_new();
                    406:        return HTError_addSystem(me->error_stack, severity, errornumber,
                    407:                                 ignore, syscall);
                    408:     }
                    409:     return NO;
2.22      frystyk   410: }
                    411: 
                    412: /*
2.59      frystyk   413: **  Set max number of automatic reload. Default is HT_MAX_RELOADS
2.22      frystyk   414: */
2.59      frystyk   415: PUBLIC BOOL HTRequest_setMaxRetry (int newmax)
2.22      frystyk   416: {
2.59      frystyk   417:     if (newmax > 0) {
                    418:        HTMaxRetry = newmax;
                    419:        return YES;
                    420:     }
                    421:     return NO;
2.22      frystyk   422: }
                    423: 
2.59      frystyk   424: PUBLIC int HTRequest_maxRetry (void)
2.22      frystyk   425: {
2.59      frystyk   426:     return HTMaxRetry;
2.22      frystyk   427: }
                    428: 
2.59      frystyk   429: PUBLIC int HTRequest_retrys (HTRequest * me)
2.22      frystyk   430: {
2.59      frystyk   431:     return me ? me->retrys : 0;
2.1       frystyk   432: }
                    433: 
2.59      frystyk   434: PUBLIC BOOL HTRequest_addRetry (HTRequest * me)
2.1       frystyk   435: {
2.59      frystyk   436:     return (me && me->retrys++);
2.71      kahan     437: }
                    438: 
                    439: PUBLIC int HTRequest_AAretrys (HTRequest * me)
                    440: {
                    441:     return me ? me->AAretrys : 0;
                    442: }
                    443: 
                    444: PUBLIC BOOL HTRequest_addAARetry (HTRequest * me)
                    445: {
                    446:     return (me && me->AAretrys++);
2.1       frystyk   447: }
                    448: 
2.18      frystyk   449: /*
2.59      frystyk   450: **     Should we try again?
                    451: **     --------------------
                    452: **     Returns YES if we are to retry the load, NO otherwise. We check
                    453: **     this so that we don't go into an infinte loop
2.1       frystyk   454: */
2.59      frystyk   455: PUBLIC BOOL HTRequest_doRetry (HTRequest * me)
2.1       frystyk   456: {
2.59      frystyk   457:     return (me && me->retrys < HTMaxRetry-1);
2.56      frystyk   458: }
                    459: 
2.1       frystyk   460: /*
2.59      frystyk   461: **     Socket mode: preemptive or non-preemptive (blocking or non-blocking)
2.40      frystyk   462: */
2.59      frystyk   463: PUBLIC void HTRequest_setPreemptive (HTRequest * me, BOOL mode)
2.40      frystyk   464: {
2.59      frystyk   465:     if (me) me->preemptive = mode;
2.40      frystyk   466: }
                    467: 
2.59      frystyk   468: PUBLIC BOOL HTRequest_preemptive (HTRequest * me)
2.40      frystyk   469: {
2.59      frystyk   470:     return me ? me->preemptive : NO;
2.40      frystyk   471: }
                    472: 
                    473: /*
2.59      frystyk   474: **     Should we use content negotiation?
2.40      frystyk   475: */
2.59      frystyk   476: PUBLIC void HTRequest_setNegotiation (HTRequest * me, BOOL mode)
2.40      frystyk   477: {
2.59      frystyk   478:     if (me) me->ContentNegotiation = mode;
2.40      frystyk   479: }
                    480: 
2.59      frystyk   481: PUBLIC BOOL HTRequest_negotiation (HTRequest * me)
2.40      frystyk   482: {
2.59      frystyk   483:     return me ? me->ContentNegotiation : NO;
2.68      frystyk   484: }
                    485: 
                    486: /*
                    487: **  Use preconditions when doing a PUT or a POST. These are the
                    488: **  if-* header fields that can be used to avoid version conflicts
                    489: **  etc.
                    490: */
2.72      frystyk   491: PUBLIC void HTRequest_setPreconditions (HTRequest * me, HTPreconditions mode)
2.68      frystyk   492: {
                    493:     if (me) me->preconditions = mode;
                    494: }
                    495: 
2.72      frystyk   496: PUBLIC HTPreconditions HTRequest_preconditions (HTRequest * me)
2.68      frystyk   497: {
                    498:     return me ? me->preconditions : NO;
2.40      frystyk   499: }
                    500: 
                    501: /*
2.59      frystyk   502: **     Set General Headers
2.1       frystyk   503: */
2.59      frystyk   504: PUBLIC void HTRequest_setGnHd (HTRequest * me, HTGnHd gnhd)
2.1       frystyk   505: {
2.59      frystyk   506:     if (me) me->GenMask = gnhd;
2.1       frystyk   507: }
                    508: 
2.59      frystyk   509: PUBLIC void HTRequest_addGnHd (HTRequest * me, HTGnHd gnhd)
2.1       frystyk   510: {
2.59      frystyk   511:     if (me) me->GenMask |= gnhd;
2.1       frystyk   512: }
                    513: 
2.59      frystyk   514: PUBLIC HTGnHd HTRequest_gnHd (HTRequest * me)
2.1       frystyk   515: {
2.59      frystyk   516:     return me ? me->GenMask : 0;
2.1       frystyk   517: }
                    518: 
                    519: /*
2.59      frystyk   520: **     Set Request Headers
2.1       frystyk   521: */
2.59      frystyk   522: PUBLIC void HTRequest_setRqHd (HTRequest * me, HTRqHd rqhd)
2.1       frystyk   523: {
2.59      frystyk   524:     if (me) me->RequestMask = rqhd;
2.1       frystyk   525: }
                    526: 
2.59      frystyk   527: PUBLIC void HTRequest_addRqHd (HTRequest * me, HTRqHd rqhd)
2.1       frystyk   528: {
2.59      frystyk   529:     if (me) me->RequestMask |= rqhd;
2.1       frystyk   530: }
                    531: 
2.59      frystyk   532: PUBLIC HTRqHd HTRequest_rqHd (HTRequest * me)
2.1       frystyk   533: {
2.59      frystyk   534:     return me ? me->RequestMask : 0;
2.1       frystyk   535: }
                    536: 
                    537: /*
2.59      frystyk   538: **     Set Response Headers
2.1       frystyk   539: */
2.59      frystyk   540: PUBLIC void HTRequest_setRsHd (HTRequest * me, HTRsHd rshd)
2.1       frystyk   541: {
2.59      frystyk   542:     if (me) me->ResponseMask = rshd;
2.1       frystyk   543: }
                    544: 
2.59      frystyk   545: PUBLIC void HTRequest_addRsHd (HTRequest * me, HTRsHd rshd)
2.35      frystyk   546: {
2.59      frystyk   547:     if (me) me->ResponseMask |= rshd;
2.35      frystyk   548: }
                    549: 
2.59      frystyk   550: PUBLIC HTRsHd HTRequest_rsHd (HTRequest * me)
2.35      frystyk   551: {
2.59      frystyk   552:     return me ? me->ResponseMask : 0;
2.35      frystyk   553: }
                    554: 
2.1       frystyk   555: /*
2.59      frystyk   556: **     Set Entity Headers (for the object)
2.34      hallam    557: */
2.59      frystyk   558: PUBLIC void HTRequest_setEnHd (HTRequest * me, HTEnHd enhd)
2.34      hallam    559: {
2.59      frystyk   560:     if (me) me->EntityMask = enhd;
2.51      frystyk   561: }
                    562: 
2.59      frystyk   563: PUBLIC void HTRequest_addEnHd (HTRequest * me, HTEnHd enhd)
2.51      frystyk   564: {
2.59      frystyk   565:     if (me) me->EntityMask |= enhd;
2.51      frystyk   566: }
                    567: 
2.59      frystyk   568: PUBLIC HTEnHd HTRequest_enHd (HTRequest * me)
2.51      frystyk   569: {
2.59      frystyk   570:     return me ? me->EntityMask : 0;
2.34      hallam    571: }
                    572: 
2.59      frystyk   573: /*
                    574: **     Extra Header Generators. list can be NULL
                    575: */
                    576: PUBLIC void HTRequest_setGenerator (HTRequest * me, HTList *generator,
                    577:                                    BOOL override)
2.34      hallam    578: {
2.59      frystyk   579:     if (me) {
                    580:        me->generators = generator;
                    581:        me->gens_local = override;
2.34      hallam    582:     }
                    583: }
                    584: 
2.59      frystyk   585: PUBLIC HTList * HTRequest_generator (HTRequest * me, BOOL *override)
2.34      hallam    586: {
2.59      frystyk   587:     if (me) {
                    588:        *override = me->gens_local;
                    589:        return me->generators;
2.34      hallam    590:     }
2.59      frystyk   591:     return NULL;
2.51      frystyk   592: }
                    593: 
2.59      frystyk   594: /*
                    595: **     Extra Header Parsers. list can be NULL
                    596: */
                    597: PUBLIC void HTRequest_setMIMEParseSet (HTRequest * me, 
                    598:                                       HTMIMEParseSet * parseSet, BOOL local)
2.51      frystyk   599: {
2.59      frystyk   600:     if (me) {
                    601:         me->parseSet = parseSet;
                    602:        me->pars_local = local;
2.51      frystyk   603:     }
2.34      hallam    604: }
                    605: 
2.59      frystyk   606: PUBLIC HTMIMEParseSet * HTRequest_MIMEParseSet (HTRequest * me, BOOL * pLocal)
2.34      hallam    607: {
2.59      frystyk   608:     if (me) {
                    609:         if (pLocal) *pLocal = me->pars_local;
                    610:        return me->parseSet;
2.34      hallam    611:     }
                    612:     return NULL;
                    613: }
                    614: 
                    615: /*
2.59      frystyk   616: **     Accept Format Types
                    617: **     list can be NULL
2.1       frystyk   618: */
2.59      frystyk   619: PUBLIC void HTRequest_setConversion (HTRequest * me, HTList *type,
                    620:                                     BOOL override)
2.1       frystyk   621: {
2.59      frystyk   622:     if (me) {
                    623:        me->conversions = type;
                    624:        me->conv_local = override;
                    625:     }
2.1       frystyk   626: }
                    627: 
2.59      frystyk   628: PUBLIC HTList * HTRequest_conversion (HTRequest * me)
2.1       frystyk   629: {
2.59      frystyk   630:     return me ? me->conversions : NULL;
2.1       frystyk   631: }
                    632: 
                    633: /*
2.59      frystyk   634: **     Accept Encoding 
                    635: **     list can be NULL
2.1       frystyk   636: */
2.59      frystyk   637: PUBLIC void HTRequest_setEncoding (HTRequest * me, HTList *enc,
                    638:                                   BOOL override)
2.1       frystyk   639: {
2.59      frystyk   640:     if (me) {
                    641:        me->encodings = enc;
                    642:        me->enc_local = override;
                    643:     }
2.1       frystyk   644: }
                    645: 
2.59      frystyk   646: PUBLIC HTList * HTRequest_encoding (HTRequest * me)
2.1       frystyk   647: {
2.59      frystyk   648:     return me ? me->encodings : NULL;
2.1       frystyk   649: }
                    650: 
                    651: /*
2.59      frystyk   652: **     Accept Transfer Encoding 
                    653: **     list can be NULL
2.1       frystyk   654: */
2.59      frystyk   655: PUBLIC void HTRequest_setTransfer (HTRequest * me,
2.64      frystyk   656:                                   HTList * te, BOOL override)
2.1       frystyk   657: {
2.59      frystyk   658:     if (me) {
2.64      frystyk   659:        me->tes = te;
                    660:        me->te_local = override;
2.59      frystyk   661:     }
2.1       frystyk   662: }
                    663: 
2.59      frystyk   664: PUBLIC HTList * HTRequest_transfer (HTRequest * me)
2.1       frystyk   665: {
2.64      frystyk   666:     return me ? me->tes : NULL;
2.47      frystyk   667: }
                    668: 
                    669: /*
2.59      frystyk   670: **     Accept Language
                    671: **     list can be NULL
2.47      frystyk   672: */
2.59      frystyk   673: PUBLIC void HTRequest_setLanguage (HTRequest * me, HTList *lang,
                    674:                                   BOOL override)
2.47      frystyk   675: {
2.59      frystyk   676:     if (me) {
                    677:        me->languages = lang;
                    678:        me->lang_local = override;
                    679:     }
2.47      frystyk   680: }
                    681: 
2.59      frystyk   682: PUBLIC HTList * HTRequest_language (HTRequest * me)
2.47      frystyk   683: {
2.59      frystyk   684:     return me ? me->languages : NULL;
2.1       frystyk   685: }
                    686: 
                    687: /*
2.59      frystyk   688: **     Accept Charset
                    689: **     list can be NULL
2.1       frystyk   690: */
2.59      frystyk   691: PUBLIC void HTRequest_setCharset (HTRequest * me, HTList *charset,
                    692:                                  BOOL override)
2.1       frystyk   693: {
2.59      frystyk   694:     if (me) {
                    695:        me->charsets = charset;
                    696:        me->char_local = override;
                    697:     }
2.1       frystyk   698: }
                    699: 
2.59      frystyk   700: PUBLIC HTList * HTRequest_charset (HTRequest * me)
2.1       frystyk   701: {
2.59      frystyk   702:     return me ? me->charsets : NULL;
2.40      frystyk   703: }
                    704: 
                    705: /*
2.53      frystyk   706: **     Are we using the full URL in the request or not?
2.40      frystyk   707: */
2.59      frystyk   708: PUBLIC void HTRequest_setFullURI (HTRequest * me, BOOL mode)
2.40      frystyk   709: {
2.59      frystyk   710:     if (me) me->full_uri = mode;
2.40      frystyk   711: }
                    712: 
2.59      frystyk   713: PUBLIC BOOL HTRequest_fullURI (HTRequest * me)
2.40      frystyk   714: {
2.59      frystyk   715:     return me ? me->full_uri : NO;
2.53      frystyk   716: }
                    717: 
                    718: /*
                    719: **     Are we using a proxy or not and in that case, which one?
                    720: */
2.59      frystyk   721: PUBLIC BOOL HTRequest_setProxy (HTRequest * me, const char * proxy)
2.53      frystyk   722: {
2.59      frystyk   723:     if (me && proxy) {
                    724:        StrAllocCopy(me->proxy, proxy);
2.53      frystyk   725:        return YES;
                    726:     }
                    727:     return NO;
                    728: }
                    729: 
2.59      frystyk   730: PUBLIC char * HTRequest_proxy (HTRequest * me)
2.53      frystyk   731: {
2.59      frystyk   732:     return me ? me->proxy : NULL;
2.1       frystyk   733: }
                    734: 
2.59      frystyk   735: PUBLIC BOOL HTRequest_deleteProxy (HTRequest * me)
2.54      frystyk   736: {
2.59      frystyk   737:     if (me) {
                    738:        HT_FREE(me->proxy);
2.54      frystyk   739:        return YES;
                    740:     }
                    741:     return NO;
                    742: }
                    743: 
2.1       frystyk   744: /*
2.59      frystyk   745: **     Reload Mode
2.1       frystyk   746: */
2.59      frystyk   747: PUBLIC void HTRequest_setReloadMode (HTRequest * me, HTReload mode)
2.1       frystyk   748: {
2.59      frystyk   749:     if (me) me->reload = mode;
2.1       frystyk   750: }
                    751: 
2.59      frystyk   752: PUBLIC HTReload HTRequest_reloadMode (HTRequest * me)
2.23      frystyk   753: {
2.59      frystyk   754:     return me ? me->reload : HT_CACHE_OK;
2.23      frystyk   755: }
                    756: 
                    757: /*
2.59      frystyk   758: **     Cache control directives. The cache control can be initiated by both
                    759: **     the server and the client which is the reason for keeping two lists
2.1       frystyk   760: */
2.59      frystyk   761: PUBLIC BOOL HTRequest_addCacheControl (HTRequest * me,
                    762:                                       char * token, char * value)
2.1       frystyk   763: {
2.59      frystyk   764:     if (me) {
                    765:        if (!me->cache_control) me->cache_control = HTAssocList_new();
                    766:        return HTAssocList_replaceObject(me->cache_control, token, value);
                    767:     }
                    768:     return NO;
2.1       frystyk   769: }
                    770: 
2.59      frystyk   771: PUBLIC BOOL HTRequest_deleteCacheControl (HTRequest * me)
2.1       frystyk   772: {
2.59      frystyk   773:     if (me && me->cache_control) {
                    774:        HTAssocList_delete(me->cache_control);
                    775:        me->cache_control = NULL;
                    776:        return YES;
                    777:     }
                    778:     return NO;
2.1       frystyk   779: }
                    780: 
2.59      frystyk   781: PUBLIC HTAssocList * HTRequest_cacheControl (HTRequest * me)
2.11      frystyk   782: {
2.59      frystyk   783:     return (me ? me->cache_control : NULL);
2.11      frystyk   784: }
                    785: 
2.59      frystyk   786: /*
                    787: **  Byte ranges
                    788: */
                    789: PUBLIC BOOL HTRequest_deleteRange (HTRequest * me)
2.11      frystyk   790: {
2.59      frystyk   791:     if (me && me->byte_ranges) {
                    792:        HTAssocList_delete(me->byte_ranges);
                    793:        me->byte_ranges = NULL;
                    794:        return YES;
2.11      frystyk   795:     }
                    796:     return NO;
                    797: }
                    798: 
2.59      frystyk   799: PUBLIC BOOL HTRequest_addRange (HTRequest * me, char * unit, char * range)
2.11      frystyk   800: {
2.59      frystyk   801:     if (me) {
2.73      frystyk   802:        if (!me->byte_ranges) {
                    803:            me->byte_ranges = HTAssocList_new();
                    804:            HTRequest_addRqHd(me, HT_C_RANGE);
                    805:        }
2.59      frystyk   806:        return HTAssocList_replaceObject(me->byte_ranges, unit, range);
2.11      frystyk   807:     }
                    808:     return NO;
                    809: }
                    810: 
2.59      frystyk   811: PUBLIC HTAssocList * HTRequest_range (HTRequest * me)
                    812: {
                    813:     return (me ? me->byte_ranges : NULL);
                    814: }
                    815: 
2.1       frystyk   816: /*
2.59      frystyk   817: **     Connection directives. The connection directies can be initiated by
                    818: **     both the server and the client which is the reason for keeping two
                    819: **     lists
2.1       frystyk   820: */
2.59      frystyk   821: PUBLIC BOOL HTRequest_addConnection (HTRequest * me,
                    822:                                     char * token, char * value)
2.1       frystyk   823: {
2.59      frystyk   824:     if (me) {
                    825:        if (!me->connection) me->connection = HTAssocList_new();
                    826:        return HTAssocList_replaceObject(me->connection, token, value);
                    827:     }
                    828:     return NO;
2.1       frystyk   829: }
                    830: 
2.59      frystyk   831: PUBLIC BOOL HTRequest_deleteConnection (HTRequest * me)
2.57      frystyk   832: {
2.59      frystyk   833:     if (me && me->connection) {
                    834:        HTAssocList_delete(me->connection);
                    835:        me->connection = NULL;
2.57      frystyk   836:        return YES;
                    837:     }
                    838:     return NO;
                    839: }
                    840: 
2.59      frystyk   841: PUBLIC HTAssocList * HTRequest_connection (HTRequest * me)
2.57      frystyk   842: {
2.59      frystyk   843:     return (me ? me->connection : NULL);
2.64      frystyk   844: }
                    845: 
                    846: /*
                    847: **     Expect directives. 
                    848: */
                    849: PUBLIC BOOL HTRequest_addExpect (HTRequest * me,
                    850:                                 char * token, char * value)
                    851: {
                    852:     if (me) {
                    853:        if (!me->expect) me->expect = HTAssocList_new();
                    854:        return HTAssocList_replaceObject(me->expect, token, value);
                    855:     }
                    856:     return NO;
                    857: }
                    858: 
                    859: PUBLIC BOOL HTRequest_deleteExpect (HTRequest * me)
                    860: {
                    861:     if (me && me->expect) {
                    862:        HTAssocList_delete(me->expect);
                    863:        me->expect = NULL;
                    864:        return YES;
                    865:     }
                    866:     return NO;
                    867: }
                    868: 
                    869: PUBLIC HTAssocList * HTRequest_expect (HTRequest * me)
                    870: {
                    871:     return (me ? me->expect : NULL);
2.57      frystyk   872: }
                    873: 
2.59      frystyk   874: /*
                    875: **  Access Authentication Credentials
                    876: */
                    877: PUBLIC BOOL HTRequest_deleteCredentialsAll (HTRequest * me)
2.57      frystyk   878: {
2.59      frystyk   879:     if (me && me->credentials) {
                    880:        HTAssocList_delete(me->credentials);
                    881:        me->credentials = NULL;
2.57      frystyk   882:        return YES;
                    883:     }
                    884:     return NO;
                    885: }
                    886: 
2.59      frystyk   887: PUBLIC BOOL HTRequest_addCredentials (HTRequest * me,
                    888:                                    char * token, char * value)
2.23      frystyk   889: {
2.59      frystyk   890:     if (me) {
                    891:        if (!me->credentials) me->credentials = HTAssocList_new();
                    892:        return HTAssocList_addObject(me->credentials, token, value);
                    893:     }
                    894:     return NO;
2.46      frystyk   895: }
                    896: 
2.59      frystyk   897: PUBLIC HTAssocList * HTRequest_credentials (HTRequest * me)
2.46      frystyk   898: {
2.59      frystyk   899:     return (me ? me->credentials : NULL);
2.23      frystyk   900: }
                    901: 
                    902: /*
2.59      frystyk   903: **  Access Authentication Realms
2.1       frystyk   904: */
2.59      frystyk   905: PUBLIC BOOL HTRequest_setRealm (HTRequest * me, char * realm)
2.1       frystyk   906: {
2.70      frystyk   907:     if (me && realm && realm != me->realm) {
2.59      frystyk   908:        StrAllocCopy(me->realm, realm);
2.1       frystyk   909:        return YES;
                    910:     }
                    911:     return NO;
                    912: }
                    913: 
2.59      frystyk   914: PUBLIC const char * HTRequest_realm (HTRequest * me)
2.1       frystyk   915: {
2.59      frystyk   916:     return (me ? me->realm : NULL);
2.70      frystyk   917: }
                    918: 
                    919: PUBLIC BOOL HTRequest_deleteRealm (HTRequest * me)
                    920: {
                    921:     if (me) {
                    922:        HT_FREE(me->realm);
                    923:        return YES;
                    924:     }
                    925:     return NO;
2.1       frystyk   926: }
                    927: 
2.59      frystyk   928: /*
                    929: **  PEP Protocol header
                    930: */
                    931: PUBLIC BOOL HTRequest_addProtocol (HTRequest * me,
                    932:                                   char * token, char * value)
2.52      frystyk   933: {
2.59      frystyk   934:     if (me) {
                    935:        if (!me->protocol) me->protocol = HTAssocList_new();
                    936:        return HTAssocList_addObject(me->protocol, token,value);
                    937:     }
                    938:     return NO;
2.52      frystyk   939: }
                    940: 
2.59      frystyk   941: PUBLIC BOOL HTRequest_deleteProtocolAll (HTRequest * me)
2.55      frystyk   942: {
2.59      frystyk   943:     if (me && me->protocol) {
                    944:        HTAssocList_delete(me->protocol);
                    945:        me->protocol = NULL;
                    946:        return YES;
                    947:     }
                    948:     return NO;
2.55      frystyk   949: }
                    950: 
2.59      frystyk   951: PUBLIC HTAssocList * HTRequest_protocol (HTRequest * me)
2.1       frystyk   952: {
2.59      frystyk   953:     return (me ? me->protocol : NULL);
2.54      frystyk   954: }
                    955: 
                    956: /*
2.59      frystyk   957: **  PEP Protocol Info header
2.54      frystyk   958: */
2.59      frystyk   959: PUBLIC BOOL HTRequest_addProtocolInfo (HTRequest * me,
                    960:                                       char * token, char * value)
2.54      frystyk   961: {
2.59      frystyk   962:     if (me) {
                    963:        if (!me->protocol_info) me->protocol_info = HTAssocList_new();
                    964:        return HTAssocList_addObject(me->protocol_info, token,value);
2.54      frystyk   965:     }
                    966:     return NO;
                    967: }
                    968: 
2.59      frystyk   969: PUBLIC BOOL HTRequest_deleteProtocolInfoAll (HTRequest * me)
2.9       frystyk   970: {
2.59      frystyk   971:     if (me && me->protocol_info) {
                    972:        HTAssocList_delete(me->protocol_info);
                    973:        me->protocol_info = NULL;
2.9       frystyk   974:        return YES;
                    975:     }
                    976:     return NO;
                    977: }
                    978: 
2.59      frystyk   979: PUBLIC HTAssocList * HTRequest_protocolInfo (HTRequest * me)
2.9       frystyk   980: {
2.59      frystyk   981:     return (me ? me->protocol_info : NULL);
2.9       frystyk   982: }
                    983: 
2.18      frystyk   984: /*
2.59      frystyk   985: **  PEP Protocol request header
2.31      frystyk   986: */
2.59      frystyk   987: PUBLIC BOOL HTRequest_addProtocolRequest (HTRequest * me,
                    988:                                          char * token, char * value)
2.49      frystyk   989: {
2.59      frystyk   990:     if (me) {
                    991:        if (!me->protocol_request) me->protocol_request = HTAssocList_new();
                    992:        return HTAssocList_addObject(me->protocol_request, token,value);
2.49      frystyk   993:     }
                    994:     return NO;
                    995: }
                    996: 
2.59      frystyk   997: PUBLIC BOOL HTRequest_deleteProtocolRequestAll (HTRequest * me)
2.31      frystyk   998: {
2.59      frystyk   999:     if (me && me->protocol_request) {
                   1000:        HTAssocList_delete(me->protocol_request);
                   1001:        me->protocol_request = NULL;
                   1002:        return YES;
2.31      frystyk  1003:     }
                   1004:     return NO;
                   1005: }
                   1006: 
2.59      frystyk  1007: PUBLIC HTAssocList * HTRequest_protocolRequest (HTRequest * me)
2.31      frystyk  1008: {
2.59      frystyk  1009:     return (me ? me->protocol_request : NULL);
2.31      frystyk  1010: }
                   1011: 
                   1012: /*
2.59      frystyk  1013: **     Anchor
2.31      frystyk  1014: */
2.59      frystyk  1015: PUBLIC void HTRequest_setAnchor (HTRequest * me, HTAnchor *anchor)
2.31      frystyk  1016: {
2.59      frystyk  1017:     if (me) {
                   1018:        me->anchor = HTAnchor_parent(anchor);
                   1019:        me->childAnchor = ((HTAnchor *) me->anchor != anchor) ?
                   1020:            (HTChildAnchor *) anchor : NULL;
2.49      frystyk  1021:     }
                   1022: }
                   1023: 
2.59      frystyk  1024: PUBLIC HTParentAnchor * HTRequest_anchor (HTRequest * me)
2.49      frystyk  1025: {
2.59      frystyk  1026:     return me ? me->anchor : NULL;
2.31      frystyk  1027: }
                   1028: 
2.59      frystyk  1029: PUBLIC HTChildAnchor * HTRequest_childAnchor (HTRequest * me)
2.31      frystyk  1030: {
2.59      frystyk  1031:     return me ? me->childAnchor : NULL;
2.31      frystyk  1032: }
                   1033: 
                   1034: /*
2.59      frystyk  1035: **     Parent anchor for Referer field
2.18      frystyk  1036: */
2.59      frystyk  1037: PUBLIC void HTRequest_setParent (HTRequest * me, HTParentAnchor *parent)
2.18      frystyk  1038: {
2.59      frystyk  1039:     if (me) me->parentAnchor = parent;
2.18      frystyk  1040: }
                   1041: 
2.59      frystyk  1042: PUBLIC HTParentAnchor * HTRequest_parent (HTRequest * me)
2.18      frystyk  1043: {
2.59      frystyk  1044:     return me ? me->parentAnchor : NULL;
2.42      frystyk  1045: }
                   1046: 
                   1047: /*
2.59      frystyk  1048: **     Output stream
2.49      frystyk  1049: */
2.59      frystyk  1050: PUBLIC void HTRequest_setOutputStream (HTRequest * me, HTStream *output)
2.49      frystyk  1051: {
2.59      frystyk  1052:     if (me) me->output_stream = output;
2.49      frystyk  1053: }
                   1054: 
2.59      frystyk  1055: PUBLIC HTStream *HTRequest_outputStream (HTRequest * me)
2.49      frystyk  1056: {
2.59      frystyk  1057:     return me ? me->output_stream : NULL;
2.49      frystyk  1058: }
                   1059: 
                   1060: /*
2.59      frystyk  1061: **     Output format
2.42      frystyk  1062: */
2.59      frystyk  1063: PUBLIC void HTRequest_setOutputFormat (HTRequest * me, HTFormat format)
2.42      frystyk  1064: {
2.59      frystyk  1065:     if (me) me->output_format = format;
                   1066: }
                   1067: 
                   1068: PUBLIC HTFormat HTRequest_outputFormat (HTRequest * me)
                   1069: {
                   1070:     return me ? me->output_format : NULL;
2.42      frystyk  1071: }
                   1072: 
2.59      frystyk  1073: /*
                   1074: **     Debug stream
                   1075: */
                   1076: PUBLIC void HTRequest_setDebugStream (HTRequest * me, HTStream *debug)
2.42      frystyk  1077: {
2.59      frystyk  1078:     if (me) me->debug_stream = debug;
2.42      frystyk  1079: }
                   1080: 
2.59      frystyk  1081: PUBLIC HTStream *HTRequest_debugStream (HTRequest * me)
2.42      frystyk  1082: {
2.59      frystyk  1083:     return me ? me->debug_stream : NULL;
2.42      frystyk  1084: }
                   1085: 
                   1086: /*
2.59      frystyk  1087: **     Debug Format
2.42      frystyk  1088: */
2.59      frystyk  1089: PUBLIC void HTRequest_setDebugFormat (HTRequest * me, HTFormat format)
2.42      frystyk  1090: {
2.59      frystyk  1091:     if (me) me->debug_format = format;
2.42      frystyk  1092: }
                   1093: 
2.59      frystyk  1094: PUBLIC HTFormat HTRequest_debugFormat (HTRequest * me)
2.42      frystyk  1095: {
2.59      frystyk  1096:     return me ? me->debug_format : NULL;
2.42      frystyk  1097: }
                   1098: 
                   1099: /*
2.59      frystyk  1100: **     Input stream
2.42      frystyk  1101: */
2.59      frystyk  1102: PUBLIC void HTRequest_setInputStream (HTRequest * me, HTStream *input)
2.42      frystyk  1103: {
2.59      frystyk  1104:     if (me) me->input_stream = input;
2.42      frystyk  1105: }
                   1106: 
2.59      frystyk  1107: PUBLIC HTStream *HTRequest_inputStream (HTRequest * me)
2.42      frystyk  1108: {
2.59      frystyk  1109:     return me ? me->input_stream : NULL;
2.18      frystyk  1110: }
                   1111: 
2.50      frystyk  1112: /*
2.59      frystyk  1113: **     Net before and after callbacks
2.50      frystyk  1114: */
2.59      frystyk  1115: PUBLIC BOOL HTRequest_addBefore (HTRequest * me, HTNetBefore * filter,
                   1116:                                 const char * tmplate, void * param,
2.60      frystyk  1117:                                 HTFilterOrder order, BOOL override)
2.50      frystyk  1118: {
2.59      frystyk  1119:     if (me) {
                   1120:        me->befores_local = override;
                   1121:        if (filter) {
                   1122:            if (!me->befores) me->befores = HTList_new();
                   1123:            return HTNetCall_addBefore(me->befores, filter,
                   1124:                                       tmplate, param, order);
                   1125:        }
                   1126:        return YES;                     /* It's OK to register a NULL filter */
2.50      frystyk  1127:     }
                   1128:     return NO;
                   1129: }
                   1130: 
2.59      frystyk  1131: PUBLIC BOOL HTRequest_deleteBefore (HTRequest * me, HTNetBefore * filter)
2.50      frystyk  1132: {
2.59      frystyk  1133:     if (me && me->befores)
                   1134:        return HTNetCall_deleteBefore(me->befores, filter);
                   1135:     return NO;
2.55      frystyk  1136: }
                   1137: 
2.59      frystyk  1138: PUBLIC BOOL HTRequest_deleteBeforeAll (HTRequest * me)
2.57      frystyk  1139: {
2.59      frystyk  1140:     if (me && me->befores) {
                   1141:        HTNetCall_deleteBeforeAll(me->befores);
                   1142:        me->befores = NULL;
                   1143:        me->befores_local = NO;
                   1144:        return YES;
2.57      frystyk  1145:     }
                   1146:     return NO;
                   1147: }
                   1148: 
2.59      frystyk  1149: PUBLIC HTList * HTRequest_before (HTRequest * me, BOOL *override)
2.57      frystyk  1150: {
2.59      frystyk  1151:     if (me) {
                   1152:        *override = me->befores_local;
                   1153:        return me->befores;
                   1154:     }
                   1155:     return NULL;
                   1156: }
                   1157: 
                   1158: PUBLIC BOOL HTRequest_addAfter (HTRequest * me, HTNetAfter * filter,
                   1159:                                const char * tmplate, void * param,
2.60      frystyk  1160:                                int status, HTFilterOrder order,
                   1161:                                BOOL override)
2.59      frystyk  1162: {
                   1163:     if (me) {
                   1164:        me->afters_local = override;
                   1165:        if (filter) {
                   1166:            if (!me->afters) me->afters = HTList_new();
                   1167:            return HTNetCall_addAfter(me->afters, filter,
                   1168:                                      tmplate, param, status, order);
                   1169:        }
                   1170:        return YES;                     /* It's OK to register a NULL filter */
2.57      frystyk  1171:     }
                   1172:     return NO;
                   1173: }
                   1174: 
2.59      frystyk  1175: PUBLIC BOOL HTRequest_deleteAfter (HTRequest * me, HTNetAfter * filter)
                   1176: {
                   1177:     return (me && me->afters) ?
                   1178:        HTNetCall_deleteAfter(me->afters, filter) : NO;
                   1179: }
                   1180: 
                   1181: PUBLIC BOOL HTRequest_deleteAfterStatus (HTRequest * me, int status)
2.57      frystyk  1182: {
2.59      frystyk  1183:     return (me && me->afters) ?
                   1184:        HTNetCall_deleteAfterStatus(me->afters, status) : NO;
2.57      frystyk  1185: }
                   1186: 
2.59      frystyk  1187: PUBLIC BOOL HTRequest_deleteAfterAll (HTRequest * me)
2.55      frystyk  1188: {
2.59      frystyk  1189:     if (me && me->afters) {
                   1190:        HTNetCall_deleteAfterAll(me->afters);
                   1191:        me->afters = NULL;
                   1192:        me->afters_local = NO;
                   1193:        return YES;
2.55      frystyk  1194:     }
                   1195:     return NO;
                   1196: }
                   1197: 
2.59      frystyk  1198: PUBLIC HTList * HTRequest_after (HTRequest * me, BOOL *override)
2.55      frystyk  1199: {
2.59      frystyk  1200:     if (me) {
                   1201:        *override = me->afters_local;
                   1202:        return me->afters;
2.55      frystyk  1203:     }
2.59      frystyk  1204:     return NULL;
                   1205: }
                   1206: 
                   1207: /*
                   1208: **     Call back function for context swapping
                   1209: */
                   1210: PUBLIC void HTRequest_setCallback (HTRequest * me, HTRequestCallback *cbf)
                   1211: {
                   1212:     if (me) me->callback = cbf;
2.55      frystyk  1213: }
                   1214: 
2.59      frystyk  1215: PUBLIC HTRequestCallback *HTRequest_callback (HTRequest * me)
2.55      frystyk  1216: {
2.59      frystyk  1217:     return me ? me->callback : NULL;
2.56      frystyk  1218: }
                   1219: 
                   1220: /*
2.59      frystyk  1221: **     Context pointer to be used in context call back function
2.56      frystyk  1222: */
2.59      frystyk  1223: PUBLIC void HTRequest_setContext (HTRequest * me, void *context)
2.56      frystyk  1224: {
2.59      frystyk  1225:     if (me) me->context = context;
2.56      frystyk  1226: }
                   1227: 
2.59      frystyk  1228: PUBLIC void *HTRequest_context (HTRequest * me)
2.56      frystyk  1229: {
2.59      frystyk  1230:     return me ? me->context : NULL;
                   1231: }
                   1232: 
                   1233: /*
                   1234: **     Has output stream been connected to the channel? If not then we
                   1235: **     must free it explicitly when deleting the request object
                   1236: */
                   1237: PUBLIC void HTRequest_setOutputConnected (HTRequest * me, BOOL mode)
                   1238: {
                   1239:     if (me) me->connected = mode;
2.56      frystyk  1240: }
                   1241: 
2.59      frystyk  1242: PUBLIC BOOL HTRequest_outputConnected (HTRequest * me)
2.56      frystyk  1243: {
2.59      frystyk  1244:     return me ? me->connected : NO;
2.56      frystyk  1245: }
                   1246: 
                   1247: /*
2.59      frystyk  1248: **     Bytes read in this request
2.56      frystyk  1249: */
2.61      frystyk  1250: PUBLIC long HTRequest_bodyRead(HTRequest * me)
2.57      frystyk  1251: {
2.69      frystyk  1252:     return me ? HTNet_bytesRead(me->net) - HTNet_headerBytesRead(me->net) : -1;
                   1253: }
                   1254: 
                   1255: /*
                   1256: **     Bytes written in this request
                   1257: */
                   1258: PUBLIC long HTRequest_bodyWritten(HTRequest * me)
                   1259: {
                   1260:     return me ? HTNet_bytesWritten(me->net) - HTNet_headerBytesWritten(me->net) : -1;
                   1261: }
                   1262: 
                   1263: /*
                   1264: **     Total Bytes read in this request
                   1265: */
                   1266: PUBLIC long HTRequest_bytesRead (HTRequest * me)
                   1267: {
                   1268:     return me ? HTNet_bytesRead(me->net) : -1;
2.57      frystyk  1269: }
                   1270: 
2.59      frystyk  1271: /*
                   1272: **     Bytes written in this request
                   1273: */
                   1274: PUBLIC long HTRequest_bytesWritten (HTRequest * me)
2.57      frystyk  1275: {
2.59      frystyk  1276:     return me ? HTNet_bytesWritten(me->net) : -1;
                   1277: }
                   1278: 
                   1279: /*
                   1280: **     Handle the max forward header value
                   1281: */
                   1282: PUBLIC BOOL HTRequest_setMaxForwards (HTRequest * me, int maxforwards)
                   1283: {
                   1284:     if (me && maxforwards >= 0) {
                   1285:        me->max_forwards = maxforwards;
                   1286:        HTRequest_addRqHd(me, HT_C_MAX_FORWARDS);              /* Turn it on */
2.57      frystyk  1287:        return YES;
                   1288:     }
                   1289:     return NO;
                   1290: }
                   1291: 
2.59      frystyk  1292: PUBLIC int HTRequest_maxForwards (HTRequest * me)
2.57      frystyk  1293: {
2.59      frystyk  1294:     return me ? me->max_forwards : -1;
2.57      frystyk  1295: }
                   1296: 
                   1297: /*
2.59      frystyk  1298: **  Source request
2.57      frystyk  1299: */
2.59      frystyk  1300: PUBLIC BOOL HTRequest_setSource (HTRequest * me, HTRequest * source)
2.57      frystyk  1301: {
2.59      frystyk  1302:     if (me) {
                   1303:        me->source = source;
                   1304:        return YES;
2.57      frystyk  1305:     }
                   1306:     return NO;
                   1307: }
                   1308: 
2.59      frystyk  1309: PUBLIC HTRequest * HTRequest_source (HTRequest * me)
2.57      frystyk  1310: {
2.59      frystyk  1311:     return (me ? me->source : NULL);
                   1312: }
                   1313: 
                   1314: PUBLIC BOOL HTRequest_isPostWeb (HTRequest * me)
                   1315: {
                   1316:     return (me ? me->source != NULL: NO);
2.57      frystyk  1317: }
                   1318: 
2.59      frystyk  1319: /*
                   1320: **     POST Call back function for sending data to the destination
                   1321: */
                   1322: PUBLIC void HTRequest_setPostCallback (HTRequest * me, HTPostCallback *cbf)
2.57      frystyk  1323: {
2.59      frystyk  1324:     if (me) me->PostCallback = cbf;
2.57      frystyk  1325: }
                   1326: 
2.59      frystyk  1327: PUBLIC HTPostCallback * HTRequest_postCallback (HTRequest * me)
2.56      frystyk  1328: {
2.59      frystyk  1329:     return me ? me->PostCallback : NULL;
2.56      frystyk  1330: }
                   1331: 
2.59      frystyk  1332: /*
                   1333: **     Entity Anchor
                   1334: */
                   1335: PUBLIC BOOL HTRequest_setEntityAnchor (HTRequest * me,
                   1336:                                       HTParentAnchor * anchor)
2.56      frystyk  1337: {
2.59      frystyk  1338:     if (me) {
                   1339:        me->source_anchor = anchor;
2.56      frystyk  1340:        return YES;
                   1341:     }
                   1342:     return NO;
                   1343: }
                   1344: 
2.59      frystyk  1345: PUBLIC HTParentAnchor * HTRequest_entityAnchor (HTRequest * me)
2.56      frystyk  1346: {
2.59      frystyk  1347:     return me ? me->source_anchor ? me->source_anchor :
                   1348:        me->anchor : NULL;
2.50      frystyk  1349: }
                   1350: 
2.1       frystyk  1351: /* ------------------------------------------------------------------------- */
                   1352: /*                             POST WEB METHODS                             */
                   1353: /* ------------------------------------------------------------------------- */
                   1354: 
                   1355: /*
                   1356: **  Add a destination request to this source request structure so that we
                   1357: **  build the internal request representation of the POST web
                   1358: **  Returns YES if OK, else NO
                   1359: */
2.23      frystyk  1360: PUBLIC BOOL HTRequest_addDestination (HTRequest * src, HTRequest * dest)
2.1       frystyk  1361: {
                   1362:     if (src && dest) {
2.23      frystyk  1363:        dest->source = src->source = src;
2.1       frystyk  1364:        if (!src->mainDestination) {
                   1365:            src->mainDestination = dest;
                   1366:            src->destRequests = 1;
2.36      frystyk  1367:            if (CORE_TRACE)
2.30      eric     1368:                HTTrace("POSTWeb..... Adding dest %p to src %p\n",
2.23      frystyk  1369:                         dest, src);
2.1       frystyk  1370:            return YES;
                   1371:        } else {
2.23      frystyk  1372:            if (!src->destinations) src->destinations = HTList_new();
2.1       frystyk  1373:            if (HTList_addObject(src->destinations, (void *) dest)==YES) {
                   1374:                src->destRequests++;
2.36      frystyk  1375:                if (CORE_TRACE)
2.30      eric     1376:                    HTTrace("POSTWeb..... Adding dest %p to src %p\n",
2.23      frystyk  1377:                             dest, src);
2.1       frystyk  1378:                return YES;
                   1379:            }
                   1380:        }
                   1381:     }
                   1382:     return NO;
                   1383: }
                   1384: 
                   1385: /*
                   1386: **  Remove a destination request from this source request structure
2.23      frystyk  1387: **  Remember only to delete the internal request objects as the other
                   1388: **  comes from the application!
2.1       frystyk  1389: **  Returns YES if OK, else NO
                   1390: */
2.23      frystyk  1391: PUBLIC BOOL HTRequest_removeDestination (HTRequest * dest)
2.1       frystyk  1392: {
                   1393:     BOOL found=NO;
                   1394:     if (dest && dest->source) {
                   1395:        HTRequest *src = dest->source;
                   1396:        if (src->mainDestination == dest) {
                   1397:            dest->source = NULL;
                   1398:            src->mainDestination = NULL;
                   1399:            src->destRequests--;
                   1400:            found = YES;
2.23      frystyk  1401:        } else if (src->destinations) {
2.1       frystyk  1402:            if (HTList_removeObject(src->destinations, (void *) dest)) {
                   1403:                src->destRequests--;
                   1404:                found = YES;
                   1405:            }
                   1406:        }
                   1407:        if (found) {
2.23      frystyk  1408:            if (dest->internal) HTRequest_delete(dest);
2.36      frystyk  1409:            if (CORE_TRACE)
2.30      eric     1410:                HTTrace("POSTWeb..... Deleting dest %p from src %p\n",
2.23      frystyk  1411:                         dest, src);
2.1       frystyk  1412:        }
2.23      frystyk  1413:        if (src->destRequests <= 0) {
2.36      frystyk  1414:            if (CORE_TRACE)
2.30      eric     1415:                HTTrace("POSTWeb..... terminated\n");
2.23      frystyk  1416:            if (src->internal) HTRequest_delete(src);
2.1       frystyk  1417:        }
                   1418:     }
                   1419:     return found;
                   1420: }
                   1421: 
                   1422: /*
2.23      frystyk  1423: **  Check to see whether all destinations are ready. If so then enable the
                   1424: **  source as ready for reading.
                   1425: **  Returns YES if all dests are ready, NO otherwise
                   1426: */
                   1427: PUBLIC BOOL HTRequest_destinationsReady (HTRequest * me)
                   1428: {
                   1429:     HTRequest * source = me ? me->source : NULL;
                   1430:     if (source) {
                   1431:        if (source->destStreams == source->destRequests) {
                   1432:            HTNet * net = source->net;
2.36      frystyk  1433:            if (CORE_TRACE)
2.30      eric     1434:                HTTrace("POSTWeb..... All destinations are ready!\n");
2.23      frystyk  1435:            if (net)                          /* Might already have finished */
2.61      frystyk  1436:                HTEvent_register(HTNet_socket(net), HTEvent_READ, &net->event);
2.23      frystyk  1437:            return YES;
                   1438:        }
                   1439:     }
                   1440:     return NO;
                   1441: }
                   1442: 
                   1443: /*
                   1444: **  Find the source request object and make the link between the 
2.1       frystyk  1445: **  source output stream and the destination input stream. There can be
                   1446: **  a conversion between the two streams!
                   1447: **  Returns YES if link is made, NO otherwise
                   1448: */
2.3       frystyk  1449: PUBLIC BOOL HTRequest_linkDestination (HTRequest *dest)
2.1       frystyk  1450: {
                   1451:     if (dest && dest->input_stream && dest->source && dest!=dest->source) {
                   1452:        HTRequest *source = dest->source;
                   1453:        HTStream *pipe = HTStreamStack(source->output_format,
                   1454:                                       dest->input_format,
                   1455:                                       dest->input_stream,
                   1456:                                       dest, YES);
                   1457: 
                   1458:        /* Check if we are the only one - else spawn off T streams */
                   1459:        /* @@@ We don't do this yet @@@ */
                   1460: 
2.23      frystyk  1461:        /* Now set up output stream of the source */
                   1462:        if (source->output_stream)
                   1463:            (*source->output_stream->isa->_free)(source->output_stream);
2.1       frystyk  1464:        source->output_stream = pipe ? pipe : dest->input_stream;
                   1465: 
2.36      frystyk  1466:        if (CORE_TRACE)
2.30      eric     1467:            HTTrace("POSTWeb..... Linking dest %p to src %p\n",
2.23      frystyk  1468:                     dest, source);
2.1       frystyk  1469:        if (++source->destStreams == source->destRequests) {
                   1470:            HTNet *net = source->net;
2.36      frystyk  1471:            if (CORE_TRACE)
2.30      eric     1472:                HTTrace("POSTWeb..... All destinations ready!\n");
2.1       frystyk  1473:            if (net)                          /* Might already have finished */
2.61      frystyk  1474:                HTEvent_register(HTNet_socket(net), HTEvent_READ, &net->event);
2.1       frystyk  1475:            return YES;
                   1476:        }
                   1477:     }
                   1478:     return NO;
                   1479: }
                   1480: 
                   1481: /*
                   1482: **  Remove a feed stream to a destination request from this source
                   1483: **  request structure. When all feeds are removed the request tree is
                   1484: **  ready to take down and the operation can be terminated.
                   1485: **  Returns YES if removed, else NO
                   1486: */
2.3       frystyk  1487: PUBLIC BOOL HTRequest_unlinkDestination (HTRequest *dest)
2.1       frystyk  1488: {
                   1489:     BOOL found = NO;
                   1490:     if (dest && dest->source && dest != dest->source) {
                   1491:        HTRequest *src = dest->source;
                   1492:        if (src->mainDestination == dest) {
                   1493:            src->output_stream = NULL;
                   1494:            if (dest->input_stream)
                   1495:                (*dest->input_stream->isa->_free)(dest->input_stream);
                   1496:            found = YES;
                   1497:        } else if (src->destinations) {
                   1498: 
                   1499:            /* LOOK THROUGH THE LIST AND FIND THE RIGHT ONE */
                   1500: 
                   1501:        }       
                   1502:        if (found) {
                   1503:            src->destStreams--;
2.36      frystyk  1504:            if (CORE_TRACE)
2.30      eric     1505:                HTTrace("POSTWeb..... Unlinking dest %p from src %p\n",
2.23      frystyk  1506:                         dest, src);
2.1       frystyk  1507:            return YES;
                   1508:        }
                   1509:     }
                   1510:     return NO;
                   1511: }
                   1512: 
                   1513: /*
                   1514: **  Removes all request structures in this PostWeb.
                   1515: */
2.3       frystyk  1516: PUBLIC BOOL HTRequest_removePostWeb (HTRequest *me)
2.1       frystyk  1517: {
                   1518:     if (me && me->source) {
                   1519:        HTRequest *source = me->source;
                   1520: 
                   1521:        /* Kill main destination */
                   1522:        if (source->mainDestination)
                   1523:            HTRequest_removeDestination(source->mainDestination);
                   1524: 
                   1525:        /* Kill all other destinations */
                   1526:        if (source->destinations) {
                   1527:            HTList *cur = source->destinations;
                   1528:            HTRequest *pres;
                   1529:            while ((pres = (HTRequest *) HTList_nextObject(cur)) != NULL)
                   1530:                HTRequest_removeDestination(pres);
                   1531:        }
                   1532: 
                   1533:        /* Remove source request */
                   1534:        HTRequest_removeDestination(source);
                   1535:        return YES;
                   1536:     }
                   1537:     return NO;
                   1538: }
                   1539: 
                   1540: /*
                   1541: **  Kills all threads in a POST WEB connected to this request but
2.23      frystyk  1542: **  NOT this request itself. We also keep the request structures.
                   1543: **  Some requests might be preemptive, for example a SMTP request (when
2.1       frystyk  1544: **  that has been implemented). However, this will be handled internally
                   1545: **  in the load function.
                   1546: */
2.3       frystyk  1547: PUBLIC BOOL HTRequest_killPostWeb (HTRequest *me)
2.1       frystyk  1548: {
                   1549:     if (me && me->source) {
                   1550:        HTRequest *source = me->source;
2.36      frystyk  1551:        if (CORE_TRACE) HTTrace("POSTWeb..... Killing\n");
2.1       frystyk  1552: 
2.23      frystyk  1553:        /*
                   1554:        ** Kill source. The stream tree is now freed so we have to build
                   1555:        ** that again. This is done in HTRequest_linkDestination()
                   1556:        */
                   1557:        if (me != source) {
                   1558:            HTNet_kill(source->net);
                   1559:            source->output_stream = NULL;
                   1560:        }
2.1       frystyk  1561: 
                   1562:        /* Kill all other destinations */
                   1563:        if (source->destinations) {
                   1564:            HTList *cur = source->destinations;
                   1565:            HTRequest *pres;
                   1566:            while ((pres = (HTRequest *) HTList_nextObject(cur)) != NULL)
2.23      frystyk  1567:                if (me != pres) HTNet_kill(pres->net);
2.1       frystyk  1568:        }
2.23      frystyk  1569: 
                   1570:        /* Kill main destination */
                   1571:        if (source->mainDestination && me != source->mainDestination)
                   1572:            HTNet_kill(source->mainDestination->net);
2.1       frystyk  1573:        return YES;
                   1574:     }
                   1575:     return NO;
2.61      frystyk  1576: }
                   1577: 
                   1578: PUBLIC int HTRequest_forceFlush (HTRequest * request)
                   1579: {
                   1580:     HTHost * host = HTNet_host(request->net);
                   1581:     if (host == NULL) return HT_ERROR;
                   1582:     return HTHost_forceFlush(host);
2.1       frystyk  1583: }
                   1584: 
                   1585: /* --------------------------------------------------------------------------*/
                   1586: /*                             Document Loader                              */
                   1587: /* --------------------------------------------------------------------------*/
                   1588: 
                   1589: /*     Request a resource
                   1590: **     ------------------
                   1591: **     This is an internal routine, which has an address AND a matching
                   1592: **     anchor.  (The public routines are called with one OR the other.)
                   1593: **     Returns:
                   1594: **             YES     if request has been registered (success)
                   1595: **             NO      an error occured
                   1596: */
2.59      frystyk  1597: PUBLIC BOOL HTLoad (HTRequest * me, BOOL recursive)
2.1       frystyk  1598: {
2.59      frystyk  1599:     if (!me || !me->anchor) {
2.36      frystyk  1600:         if (CORE_TRACE) HTTrace("Load Start.. Bad argument\n");
2.1       frystyk  1601:         return NO;
                   1602:     }
2.57      frystyk  1603: 
                   1604:     /* Make sure that we don't carry over any old physical address */
2.63      frystyk  1605:     if (!recursive) HTAnchor_clearPhysical(me->anchor);
2.57      frystyk  1606: 
2.59      frystyk  1607:     /* Set the default method if not already done */
                   1608:     if (me->method == METHOD_INVALID) me->method = METHOD_GET;
2.57      frystyk  1609: 
                   1610:     /* Should we keep the error stack or not? */
2.59      frystyk  1611:     if (!recursive && me->error_stack) {
                   1612:        HTError_deleteAll(me->error_stack);
                   1613:        me->error_stack = NULL;
                   1614:     }
                   1615: 
                   1616:     /* Delete any old Response Object */
                   1617:     if (me->response) {
                   1618:        HTResponse_delete(me->response);
                   1619:        me->response = NULL;
2.16      frystyk  1620:     }
2.57      frystyk  1621: 
                   1622:     /*
                   1623:     **  We set the start point of handling a request to here.
                   1624:     **  This time will be used by the cache
                   1625:     */
2.59      frystyk  1626:     HTRequest_setDate(me, time(NULL));
2.57      frystyk  1627: 
                   1628:     /* Now start the Net Manager */
2.59      frystyk  1629:     return HTNet_newClient(me);
2.1       frystyk  1630: }
                   1631: 
2.74      frystyk  1632: PUBLIC BOOL HTServe (HTRequest * me, BOOL recursive)
                   1633: {
                   1634:     if (!me || !me->anchor) {
                   1635:         if (CORE_TRACE) HTTrace("Serve Start. Bad argument\n");
                   1636:         return NO;
                   1637:     }
                   1638: 
                   1639:     /* Make sure that we don't carry over any old physical address */
                   1640:     if (!recursive) HTAnchor_clearPhysical(me->anchor);
                   1641: 
                   1642:     /* Should we keep the error stack or not? */
                   1643:     if (!recursive && me->error_stack) {
                   1644:        HTError_deleteAll(me->error_stack);
                   1645:        me->error_stack = NULL;
                   1646:     }
                   1647: 
                   1648:     /* Delete any old Response Object */
                   1649:     if (me->response) {
                   1650:        HTResponse_delete(me->response);
                   1651:        me->response = NULL;
                   1652:     }
                   1653: 
                   1654:     /* Now start the Net Manager */
                   1655:     return HTNet_newServer(me);
                   1656: }

Webmaster