MCPcopy Create free account
hub / github.com/SOUI2/soui / ParseRequest

Method ParseRequest

demo/httpsvr/HTTPServer.cpp:182–327  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

180
181
182BOOL CHTTPServer::ParseRequest(string szRequest, string &szResponse, BOOL &bKeepAlive)
183{
184 //
185 // Simple Parsing of Request
186 //
187 string szMethod;
188 string szFileName;
189 string szFileExt;
190 string szStatusCode("200 OK");
191 string szContentType("text/html");
192 string szConnectionType("close");
193 string szNotFoundMessage;
194 string szDateTime;
195 char pResponseHeader[2048];
196 unsigned int lengthActual = 0, length = 0;
197 char *pBuf = NULL;
198 int n;
199
200 //
201 // Check Method
202 //
203 n = szRequest.find(" ", 0);
204 if(n != string::npos)
205 {
206 szMethod = szRequest.substr(0, n);
207 if(szMethod == "GET")
208 {
209 //
210 // Get file name
211 //
212 int n1 = szRequest.find(" ", n + 1);
213 if(n != string::npos)
214 {
215 szFileName = szRequest.substr(n + 1, n1 - n - 1);
216 if(szFileName == "/")
217 {
218 szFileName = m_DefIndex;
219 }
220 }
221 else
222 {
223 LogMessage(LOGFILENAME, _T("No 'space' found in Request String #1"), _T("ParseRequest"));
224 return FALSE;
225 }
226 }
227 else
228 {
229 szStatusCode = "501 Not Implemented";
230 szFileName = ERROR501;
231 }
232 }
233 else
234 {
235 LogMessage(LOGFILENAME, _T("No 'space' found in Request String #2"), _T("ParseRequest"));
236 return FALSE;
237 }
238
239 //

Callers 1

ClientThreadMethod · 0.80

Calls 10

strftimeFunction · 0.85
findMethod · 0.45
rfindMethod · 0.45
sizeMethod · 0.45
c_strMethod · 0.45
endMethod · 0.45
OpenMethod · 0.45
LengthMethod · 0.45
ReadMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected