source: trunk/gsdl/src/w32server/httpsend.cpp@ 1293

Last change on this file since 1293 was 611, checked in by sjboddie, 25 years ago

initial commit of windows server code

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.9 KB
Line 
1/*
2Copyright (C) 1996
3
4This program is free software; you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation; either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program; if not, write to the Free Software
16Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18The author can be contacted via Email at [email protected]
19*/
20#include <windows.h>
21#include <stdlib.h>
22#include <stdio.h>
23#include <string.h>
24#include <memory.h>
25#pragma hdrstop
26#include "parse.h"
27#include "netio.h"
28#include "httpreq.h"
29#include "httpsend.h"
30
31//Private Function Declarations
32/*
33Function Name: Check IMS Date
34Purpose: Checks the string date of an "If Modified Since" header against
35 a file date stamp.
36Parameters:
37 FileTime - Time stamp on file
38 IMSStr - "If Modified Since" date string
39Returns: TRUE if the file has been modified since the given date or
40 the data can not be resolved (the string to date function will log
41 any errors)
42*/
43BOOL CheckIMSDate(SYSTEMTIME &FileTime, char *IMSStr);
44
45//Public Functions
46/******************************************************************************/
47
48void SendHTTPError(int ErrorNum, char *ErrorTitleStr, char *ErrorDescStr, RequestInfoT &RequestInfo, RequestFieldsT &RequestFields)
49{
50 char Header[512];
51 char Body[512];
52
53 char ErrorNumStr[17];
54
55 DWORD BodyLength;
56 char BodyLengthStr[17];
57
58 int HeaderLength;
59
60 itoa(ErrorNum, ErrorNumStr, 10);
61
62 //Didn't find it, build the message manualry
63 Body[0] = 0;
64 strcat(Body, "<HTML><HEAD><TITLE>Server Error</TITLE></HEAD><BODY>\n");
65 strcat(Body, "<H1>Error ");
66 strcat(Body, ErrorNumStr);
67 strcat(Body, ": ");
68 strcat(Body, ErrorTitleStr);
69 strcat(Body, "</H1>\n");
70 strcat(Body, ErrorDescStr);
71 strcat(Body, "\n</BODY></HTML>");
72 BodyLength = (DWORD) strlen(Body);
73
74 //Build Header
75 Header[0] = 0;
76 //Status Line
77 strcat(Header, "HTTP/1.0 ");
78 strcat(Header, ErrorNumStr);
79 strcat(Header, " ");
80 strcat(Header, ErrorDescStr);
81 strcat(Header, "\r\n");
82 //Server
83 strcat(Header, "Server: GSDL\r\n");
84 //Content Type (assume HTML)
85 strcat(Header, "Content-Type: text/html\r\n");
86 //Content Length
87 itoa(BodyLength, BodyLengthStr, 10);
88 strcat(Header, "Content-Length: ");
89 strcat(Header, BodyLengthStr);
90 strcat(Header, "\r\n");
91 //Single CRLF to end header
92 strcat(Header, "\r\n");
93
94 HeaderLength = strlen(Header);
95
96 //Send header
97 SendData(RequestInfo.ClientSocket, (BYTE *) Header, strlen(Header), RequestInfo.ThreadNum);
98 //Send generated data
99 SendData(RequestInfo.ClientSocket, (BYTE *) Body, BodyLength, RequestInfo.ThreadNum);
100}
Note: See TracBrowser for help on using the repository browser.