1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Class Poco::Net::AbstractHTTPRequestHandler</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<meta name="author" content="Applied Informatics Software Engineering GmbH and Contributors"/>
<meta name="publisher" content="Applied Informatics Software Engineering GmbH and Contributors"/>
<meta name="copyright" content="Copyright (c) 2009, Applied Informatics Software Engineering GmbH and Contributors"/>
<meta name="language" content="en"/>
<meta name="date" content="2009-11-24"/>
<meta name="generator" content="PocoDoc"/>
<link rel="stylesheet" href="css/styles.css" type="text/css"/>
</head>
<body bgcolor="#ffffff" leftmargin="0" topmargin="0">
<div class="header">
<h1 class="namespace"><a href="Poco.Net.html" class="namespace">Poco::Net</a></h1>
<h1 class="symbol">class AbstractHTTPRequestHandler</h1>
</div>
<div class="body">
<p>
<b>Library:</b> Net<br />
<b>Package:</b> HTTPServer<br />
<b>Header:</b> Poco/Net/AbstractHTTPRequestHandler.h</p>
<h2>Description</h2>
<div class="description">
<p>The abstract base class for AbstractHTTPRequestHandlers created by <a href="Poco.Net.HTTPServer.html" title="class Poco::Net::HTTPServer">HTTPServer</a>. </p>
<p>Derived classes must override the <a href="Poco.Net.AbstractHTTPRequestHandler.html#12114" title="Poco::Net::AbstractHTTPRequestHandler::run()">run</a>() method. Contrary to a <a href="Poco.Net.HTTPRequestHandler.html" title="class Poco::Net::HTTPRequestHandler">HTTPRequestHandler</a>, an <a href="Poco.Net.AbstractHTTPRequestHandler.html" title="class Poco::Net::AbstractHTTPRequestHandler">AbstractHTTPRequestHandler</a> stores request and response as member variables to avoid having to pass them around as method parameters. Additionally, a <a href="Poco.Net.HTMLForm.html" title="class Poco::Net::HTMLForm">HTMLForm</a> object is created for use by subclasses. </p>
<p>The <a href="Poco.Net.AbstractHTTPRequestHandler.html#12114" title="Poco::Net::AbstractHTTPRequestHandler::run()">run</a>() method must perform the complete handling of the HTTP request connection. As soon as the <a href="Poco.Net.AbstractHTTPRequestHandler.html#12114" title="Poco::Net::AbstractHTTPRequestHandler::run()">run</a>() method returns, the request handler object is destroyed. </p>
<p>A new <a href="Poco.Net.AbstractHTTPRequestHandler.html" title="class Poco::Net::AbstractHTTPRequestHandler">AbstractHTTPRequestHandler</a> object will be created for each new HTTP request that is received by the <a href="Poco.Net.HTTPServer.html" title="class Poco::Net::HTTPServer">HTTPServer</a>. </p>
</div>
<h2>Inheritance</h2>
<p><b>Direct Base Classes: </b><a href="Poco.Net.HTTPRequestHandler.html" title="class Poco::Net::HTTPRequestHandler">HTTPRequestHandler</a></p>
<p><b>All Base Classes: </b><a href="Poco.Net.HTTPRequestHandler.html" title="class Poco::Net::HTTPRequestHandler">HTTPRequestHandler</a></p>
<h2>Member Summary</h2>
<p><b>Member Functions: </b><a href="Poco.Net.AbstractHTTPRequestHandler.html#12115" title="Poco::Net::AbstractHTTPRequestHandler::authenticate()">authenticate</a>, <a href="Poco.Net.AbstractHTTPRequestHandler.html#12110" title="Poco::Net::AbstractHTTPRequestHandler::form()">form</a>, <a href="Poco.Net.AbstractHTTPRequestHandler.html#12105" title="Poco::Net::AbstractHTTPRequestHandler::handleRequest()">handleRequest</a>, <a href="Poco.Net.AbstractHTTPRequestHandler.html#12108" title="Poco::Net::AbstractHTTPRequestHandler::request()">request</a>, <a href="Poco.Net.AbstractHTTPRequestHandler.html#12109" title="Poco::Net::AbstractHTTPRequestHandler::response()">response</a>, <a href="Poco.Net.AbstractHTTPRequestHandler.html#12114" title="Poco::Net::AbstractHTTPRequestHandler::run()">run</a>, <a href="Poco.Net.AbstractHTTPRequestHandler.html#12111" title="Poco::Net::AbstractHTTPRequestHandler::sendErrorResponse()">sendErrorResponse</a></p>
<p><b>Inherited Functions: </b><a href="Poco.Net.HTTPRequestHandler.html#12875" title="Poco::Net::HTTPRequestHandler::handleRequest()">handleRequest</a></p>
<h2>Constructors</h2>
<h3><a name="12103">AbstractHTTPRequestHandler</a></h3>
<p class="decl"><a href="Poco.Net.AbstractHTTPRequestHandler.html" title="class Poco::Net::AbstractHTTPRequestHandler">AbstractHTTPRequestHandler</a>();</p>
<div class="description">
<p>Creates the <a href="Poco.Net.AbstractHTTPRequestHandler.html" title="class Poco::Net::AbstractHTTPRequestHandler">AbstractHTTPRequestHandler</a>. </p>
</div>
<h2>Destructor</h2>
<h3><a name="12104">~AbstractHTTPRequestHandler</a> <img src="images/virtual.gif" alt="virtual" title="virtual" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">virtual ~<a href="Poco.Net.AbstractHTTPRequestHandler.html" title="class Poco::Net::AbstractHTTPRequestHandler">AbstractHTTPRequestHandler</a>();</p>
<div class="description">
<p>Destroys the <a href="Poco.Net.AbstractHTTPRequestHandler.html" title="class Poco::Net::AbstractHTTPRequestHandler">AbstractHTTPRequestHandler</a>. </p>
</div>
<h2>Member Functions</h2>
<h3><a name="12110">form</a></h3>
<p class="decl"><a href="Poco.Net.HTMLForm.html" title="class Poco::Net::HTMLForm">HTMLForm</a> & form();</p>
<div class="description">
<p>Returns a <a href="Poco.Net.HTMLForm.html" title="class Poco::Net::HTMLForm">HTMLForm</a> for the given request. The <a href="Poco.Net.HTMLForm.html" title="class Poco::Net::HTMLForm">HTMLForm</a> object is created when this member function is executed the first time. </p>
</div>
<h3><a name="12105">handleRequest</a> <img src="images/virtual.gif" alt="virtual" title="virtual" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">void handleRequest(<br /> <a href="Poco.Net.HTTPServerRequest.html" title="class Poco::Net::HTTPServerRequest">HTTPServerRequest</a> & request,<br /> <a href="Poco.Net.HTTPServerResponse.html" title="class Poco::Net::HTTPServerResponse">HTTPServerResponse</a> & response<br />);</p>
<div class="description">
<p>This class implements some common behavior, before calling <a href="Poco.Net.AbstractHTTPRequestHandler.html#12114" title="Poco::Net::AbstractHTTPRequestHandler::run()">run</a>() to actually handle the request: </p>
<ul>
<li>save request and response objects; </li>
<li>call authorize(); </li>
<li>if authorize() returns true call <a href="Poco.Net.AbstractHTTPRequestHandler.html#12114" title="Poco::Net::AbstractHTTPRequestHandler::run()">run</a>(), else send 401 (Unauthorized) response. </li>
</ul>
<p>If <a href="Poco.Net.AbstractHTTPRequestHandler.html#12114" title="Poco::Net::AbstractHTTPRequestHandler::run()">run</a>() throws an exception and the response has not been sent yet, sends a 500 (Internal Server Error) response with the exception's display text. </p>
</div>
<div class="description"><p><b>See also:</b> <a href="Poco.Net.HTTPRequestHandler.html#12875" title="Poco::Net::HTTPRequestHandler::handleRequest()">Poco::Net::HTTPRequestHandler::handleRequest()</a></p></div>
<h3><a name="12108">request</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl"><a href="Poco.Net.HTTPServerRequest.html" title="class Poco::Net::HTTPServerRequest">HTTPServerRequest</a> & request();</p>
<div class="description">
<p>Returns the request. </p>
</div>
<h3><a name="12109">response</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl"><a href="Poco.Net.HTTPServerResponse.html" title="class Poco::Net::HTTPServerResponse">HTTPServerResponse</a> & response();</p>
<div class="description">
<p>Returns the response. </p>
</div>
<h3><a name="12111">sendErrorResponse</a></h3>
<p class="decl">void sendErrorResponse(<br /> <a href="Poco.Net.HTTPResponse.html#12893" title="enum Poco::Net::HTTPResponse::HTTPStatus">HTTPResponse::HTTPStatus</a> status,<br /> const std::string & message<br />);</p>
<div class="description">
<p>Sends a HTML error page for the given status code. The given message is added to the page: </p>
<pre><HTML>
<HEAD>
<TITLE>status - reason</TITLE>
</HEAD>
<BODY>
<H1>status - reason</H1>
<P>message</P>
</BODY>
</HTML>
</pre>
</div>
<h3><a name="12115">authenticate</a> <img src="images/protected.gif" alt="protected" title="protected" style="vertical-align:baseline;" border="0" /> <img src="images/virtual.gif" alt="virtual" title="virtual" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">virtual bool authenticate();</p>
<div class="description">
<p>Check authentication; returns true if okay, false if failed to authenticate. The default implementation always returns true. </p>
<p>Subclasses can override this member function to perform some form of client or request authentication before the request is actually handled. </p>
</div>
<h3><a name="12114">run</a> <img src="images/protected.gif" alt="protected" title="protected" style="vertical-align:baseline;" border="0" /> <img src="images/virtual.gif" alt="virtual" title="virtual" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">virtual void run() = 0;</p>
<div class="description">
<p>Must be overridden by subclasses. </p>
<p>Handles the given request. </p>
</div>
<p class="footer">POCO C++ Libraries 1.3.6-all<br />
Copyright © 2009, <a href="http://pocoproject.org/" target="_blank">Applied Informatics Software Engineering GmbH and Contributors</a></p>
</div>
</body>
</html>
|