Changeset 2280


Ignore:
Timestamp:
2001-04-04T22:37:36+12:00 (23 years ago)
Author:
sjboddie
Message:

In the process of making some changes to the old fnord webserver code.
Note that this version is BROKEN, I just committed it so I could continue
the work I've been doing on my home PC at work.

Location:
trunk/gsdl/src/w32server
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/w32server/cgiwrapper.cpp

    r2212 r2280  
    766766}
    767767
    768 int ExamineURIStr(char *URIStr, RequestInfoT *RequestInfo,
     768int ExamineURIStr(text_t &URIStr, RequestInfoT *RequestInfo,
    769769          RequestFieldsT *RequestFields)
    770770{
    771771  char *protocol, *machine, *rest;  int port;
    772   char URICopyA[MAX_URL_SIZE], URICopyB[MAX_URL_SIZE];
     772  //  char URICopyA[MAX_URL_SIZE], URICopyB[MAX_URL_SIZE];
    773773
    774774  if (RequestFields->ContentLength > 0) {
    775775    // POST data
    776     int len = strlen (URIStr);
     776    URIStr.push_back('?');
     777    URIStr += (char*)RequestFields->Content;
     778
     779    //    int len = strlen (URIStr);
    777780    // fail relatively gracefully (and mysteriously) if POST
    778781    // arguments are too long
    779     if (len + RequestFields->ContentLength + 1 <= MAX_URL_SIZE) {
    780       URIStr[len] = '?'; len ++;
    781       for (int i = 0; i < RequestFields->ContentLength; i++) {
    782     URIStr[len] = RequestFields->Content[i];
    783     len ++;
    784       }
    785       URIStr[len] = '\0';
    786     } else {
    787       MessageBox (NULL, "POST data too long", "Greenstone Digital Library Software", MB_OK);
    788     }
    789   }
    790 
    791   strcpy(URICopyA,URIStr);
     782    //    if (len + RequestFields->ContentLength + 1 <= MAX_URL_SIZE) {
     783    //      URIStr[len] = '?'; len ++;
     784    //      for (int i = 0; i < RequestFields->ContentLength; i++) {
     785    //  URIStr[len] = RequestFields->Content[i];
     786    //  len ++;
     787    //      }
     788    //      URIStr[len] = '\0';
     789    //    } else {
     790    //      MessageBox (NULL, "POST data too long", "Greenstone Digital Library Software", MB_OK);
     791    //    }
     792  }
     793 
     794  char *URICopyA = URIStr.getcstr();
     795  char URICopyB[MAX_URL_SIZE];
     796  char *URICopytmp = URIStr.getcstr();
     797
     798    //  strcpy(URICopyA,URIStr);
    792799 
    793800  if (parse_url(URICopyA,&protocol,&machine,&port,&rest)!=http_ok) {
    794801    /* Alter local file request to address 'gsdl' */
    795     fix_prefix(URICopyB, "http://gsdl", URIStr);
     802    //    fix_prefix(URICopyB, "http://gsdl", URIStr);
     803    fix_prefix(URICopyB, "http://gsdl", URICopytmp);
    796804    URIStr = URICopyB;
    797805    strcpy(URICopyA, URICopyB);
  • trunk/gsdl/src/w32server/cgiwrapper.h

    r1739 r2280  
    3434extern int libaccessnum;
    3535
    36 int ExamineURIStr(char *URIStr,RequestInfoT *RequestInfo,
     36int ExamineURIStr(text_t &URIStr,RequestInfoT *RequestInfo,
    3737          RequestFieldsT *RequestFields);
    3838
  • trunk/gsdl/src/w32server/httpreq.cpp

    r1203 r2280  
    245245    //No version, assume simple request
    246246    //part after method is URI
    247     memcpy(RequestFields.URIStr, CurLine + End, strlen(CurLine) + 1 - End);
     247    for (int i = 0; i < strlen(CurLine); i++) {
     248      RequestFields.URIStr.push_back(CurLine[i]);
     249    }
    248250    return GH_SIMPLE_REQUEST;
    249251  }
     
    252254  //<Method> <WhiteSpace> <URI> <WhiteSpace> <Version> <CRLF>
    253255  //                  End^             Start^
    254   int URIStrLen = Start - End;;
    255   if (URIStrLen > ReqURIStrLen-1) URIStrLen = ReqURIStrLen - 1;
    256   memcpy(RequestFields.URIStr, CurLine + End, URIStrLen);
    257   RequestFields.URIStr[URIStrLen] = 0;
    258   TrimRight(RequestFields.URIStr); //Remove trailing space
     256  text_t spacebuffer;
     257  for (int i = End; i < Start; i++) {
     258    // do this to remove trailing space
     259    if (CurLine[i] == ' ') {
     260      spacebuffer.push_back(' ');
     261    } else {
     262      if (!spacebuffer.empty()) {
     263    RequestFields.URIStr += spacebuffer;
     264    spacebuffer.clear();
     265      }
     266      RequestFields.URIStr.push_back(CurLine[i]);
     267    }
     268  }
    259269 
    260270  //Only accept requests from HTTP/0.9 or HTTP/1.X clients, we'll
  • trunk/gsdl/src/w32server/httpreq.h

    r2038 r2280  
    33
    44#include "locate.h"
     5#include "text_t.h"
    56
    67/*
     
    4344//Length constants for RequestFieldsT
    4445#define ReqMethodStrLen           24
    45 #define ReqURIStrLen             255
     46//#define ReqURIStrLen             255
    4647#define ReqVersionStrLen          24
    4748#define ReqDateStrLen             48
     
    6970
    7071struct RequestHeaderT {
    71     char *Var;
    72    char *Val;
    73     };
     72  char *Var;
     73  char *Val;
     74};
    7475
    7576struct RequestFieldsT {
    76     //Simple request line info v0.9
    77     char MethodStr[ReqMethodStrLen];
     77  //Simple request line info v0.9
     78  char MethodStr[ReqMethodStrLen];
    7879  //    char URIStr[ReqURIStrLen];
    79     char URIStr[MAX_URL_SIZE];
    80     //added v1.0
    81     char VersionStr[ReqVersionStrLen];
    82     //General Header
    83     char DateStr[ReqDateStrLen];
    84     char MIMEVerStr[ReqMIMEVerStrLen];
    85     char PragmaStr[ReqPragmaStrLen];
    86     //Request Header
    87     char AuthorizationStr[ReqAuthorizationStrLen];
    88     char FromStr[ReqFromStrLen];
    89     char IfModSinceStr[ReqIfModSinceStrLen];
    90     char RefererStr[ReqRefererStrLen];
    91     char UserAgentStr[ReqUserAgentStrLen];
    92     //Entity Header (Only CGI stuff)
    93     char ContentEncodingStr[ReqContentEncodingStrLen];
    94     char ContentTypeStr[ReqContentTypeStrLen];
    95     char ContentLengthStr[ReqContentLengthStrLen];
    96    //v1.0 Optional (the more common ones)
    97    char AcceptStr[ReqAcceptStrLen];
    98    char AcceptLangStr[ReqAcceptLangStrLen];
    99     //v1.1 Exentions
    100     char ConnectionStr[ReqConnectionStrLen];
    101     //Pointer to buffer containing the content
    102     DWORD ContentLength;
    103     BYTE *Content;
    104 
    105     //Authorized user, filled in if a user is authorized from Auth..Str above
    106     char AuthorizedUserStr[ReqAuthorizedUserStrLen];
    107 
    108    //CGI style fields
    109    char PathInfoStr[ReqPathInfoStrLen];
    110    char PathTranslatedStr[ReqPathTranslatedStrLen];
    111    char ScriptNameStr[ReqScriptNameStrLen];
    112 
    113    //Other Headers
    114    int NumOtherHeaders;
    115    RequestHeaderT OtherHeaders[MAX_OTHER_HEADERS];
    116     };
     80  text_t URIStr;
     81  //added v1.0
     82  char VersionStr[ReqVersionStrLen];
     83  //General Header
     84  char DateStr[ReqDateStrLen];
     85  char MIMEVerStr[ReqMIMEVerStrLen];
     86  char PragmaStr[ReqPragmaStrLen];
     87  //Request Header
     88  char AuthorizationStr[ReqAuthorizationStrLen];
     89  char FromStr[ReqFromStrLen];
     90  char IfModSinceStr[ReqIfModSinceStrLen];
     91  char RefererStr[ReqRefererStrLen];
     92  char UserAgentStr[ReqUserAgentStrLen];
     93  //Entity Header (Only CGI stuff)
     94  char ContentEncodingStr[ReqContentEncodingStrLen];
     95  char ContentTypeStr[ReqContentTypeStrLen];
     96  char ContentLengthStr[ReqContentLengthStrLen];
     97  //v1.0 Optional (the more common ones)
     98  char AcceptStr[ReqAcceptStrLen];
     99  char AcceptLangStr[ReqAcceptLangStrLen];
     100  //v1.1 Exentions
     101  char ConnectionStr[ReqConnectionStrLen];
     102  //Pointer to buffer containing the content
     103  DWORD ContentLength;
     104  BYTE *Content;
     105 
     106  //Authorized user, filled in if a user is authorized from Auth..Str above
     107  char AuthorizedUserStr[ReqAuthorizedUserStrLen];
     108 
     109  //CGI style fields
     110  char PathInfoStr[ReqPathInfoStrLen];
     111  char PathTranslatedStr[ReqPathTranslatedStrLen];
     112  char ScriptNameStr[ReqScriptNameStrLen];
     113 
     114  //Other Headers
     115  int NumOtherHeaders;
     116  RequestHeaderT OtherHeaders[MAX_OTHER_HEADERS];
     117};
    117118
    118119struct RequestInfoT {
    119     int ThreadNum;
    120 
    121     //Buffer for IO operations (so we're not constantly reallocating buffers)
    122     BYTE *IOBuffer;
    123    int IOBufferSize;
    124 
    125     //Socket the request is on and its address
    126     SOCKET ClientSocket;
    127     SOCKADDR_IN ClientSockAddr;
    128     int AddrLen;
    129 
    130     //Should we keep the connection alive?
    131     BOOL KeepAlive;
    132     };
     120  int ThreadNum;
     121 
     122  //Buffer for IO operations (so we're not constantly reallocating buffers)
     123  BYTE *IOBuffer;
     124  int IOBufferSize;
     125 
     126  //Socket the request is on and its address
     127  SOCKET ClientSocket;
     128  SOCKADDR_IN ClientSockAddr;
     129  int AddrLen;
     130 
     131  //Should we keep the connection alive?
     132  BOOL KeepAlive;
     133};
    133134
    134135
  • trunk/gsdl/src/w32server/httpsend.cpp

    r611 r2280  
    2424#include <memory.h>
    2525#pragma hdrstop
    26 #include "parse.h"
    2726#include "netio.h"
    2827#include "httpreq.h"
Note: See TracChangeset for help on using the changeset viewer.