MCPcopy Create free account
hub / github.com/cuberite/cuberite / OnRequestFinished

Method OnRequestFinished

src/HTTPServer/HTTPServer.cpp:53–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51
52
53 virtual void OnRequestFinished(cHTTPConnection & a_Connection, cHTTPRequest & a_Request) override
54 {
55 cHTTPFormParser * FormParser = (cHTTPFormParser *)(a_Request.GetUserData());
56 if (FormParser != NULL)
57 {
58 if (FormParser->Finish())
59 {
60 cHTTPResponse Resp;
61 Resp.SetContentType("text/html");
62 a_Connection.Send(Resp);
63 a_Connection.Send("<html><body><table border=1 cellspacing=0><tr><th>Name</th><th>Value</th></tr>\r\n");
64 for (cHTTPFormParser::iterator itr = FormParser->begin(), end = FormParser->end(); itr != end; ++itr)
65 {
66 a_Connection.Send(Printf("<tr><td valign=\"top\"><pre>%s</pre></td><td valign=\"top\"><pre>%s</pre></td></tr>\r\n", itr->first.c_str(), itr->second.c_str()));
67 } // for itr - FormParser[]
68 a_Connection.Send("</table></body></html>");
69 return;
70 }
71
72 // Parsing failed:
73 cHTTPResponse Resp;
74 Resp.SetContentType("text/plain");
75 a_Connection.Send(Resp);
76 a_Connection.Send("Form parsing failed");
77 return;
78 }
79
80 // Test the auth failure and success:
81 if (a_Request.GetURL() == "/auth")
82 {
83 if (!a_Request.HasAuth() || (a_Request.GetAuthUsername() != "a") || (a_Request.GetAuthPassword() != "b"))
84 {
85 a_Connection.SendNeedAuth("MCServer WebAdmin");
86 return;
87 }
88 }
89
90 cHTTPResponse Resp;
91 Resp.SetContentType("text/plain");
92 a_Connection.Send(Resp);
93 a_Connection.Send("Hello, world");
94 }
95
96
97 virtual void OnFileStart(cHTTPFormParser & a_Parser, const AString & a_FileName) override

Callers 1

RequestFinishedMethod · 0.45

Calls 10

PrintfFunction · 0.85
GetUserDataMethod · 0.80
SetContentTypeMethod · 0.80
beginMethod · 0.80
endMethod · 0.80
c_strMethod · 0.80
HasAuthMethod · 0.80
SendNeedAuthMethod · 0.80
FinishMethod · 0.45
SendMethod · 0.45

Tested by

no test coverage detected