-
Notifications
You must be signed in to change notification settings - Fork 4
DevDoc: Processing a request
When an installation of BeeHub receives a request, first the web server deals with it to decide what to do with it. The .htaccess file is configured to:
- Serve every file that exists in the document root (/public) 'as is'
- Otherwise, pass the request to
(/public)/index.php, so that it is handled there (and this is actual BeeHub code processing it, then).
When the request needs to be handled by BeeHub, (/public)/index.php:
- assembles all needed dependencies and initialises the BeeHub request handling with the installed configuration (bootstrapping)
This involves creating an instance of DAV_Registry, which in our configuration is set up to be a BeeHub_Registry instance
- it authenticates
- upon success, begins to build the response
DAV_Request.php will create an appropriate instance of DAV_Request based on the HTTP request method (i.e.: an instance of one of DAV_Request_XXX, such as DAV_Request_GET, DAV_Request_HEAD, etc.)
- Finally,
index.phpwill invokehandleRequest()on theDAV_Request_XXXinstance. That instance knows how to interpret the user's request, undestands it and processes it to create the adequate response.
The DAV_Request_XXX instance first goes through the handleRequest() method in the parent DAV_Request.php:
- Check that the resource in the request exists and is visible to the user.
It fetches a proper instance of DAV_Resource from the DAV_Registry (i.e.: an instance of a subclass of BeeHub_Resource such as BeeHub_File, BeeHub_Sponsor, etc.) and makes it available for the request handler.
- Check that the HTTP method is valid
- Call the
handle()method on theDAV_Request_XXXclass.
Then, the handle() method:
- Can access the resource representation
- Streams the proper HTTP headers
- Streams the body of the HTTP response
- Possibly making use of the
method_XXX()of the resource, whereXXXmatches the requested HTTP method. Note however, that other methods of the resource can also be used! - And this
method_XXX()may look into the request details to decide what kind of answer to give back. For example, themethod_GET()of aBeeHub_Directoryalways gives an HTML page back. And in case that such an HTML must be the response, there is a view resolver method calledinclude_view()inBeeHub_resource.phpthat introspects on the request and delivers the right HTML by finding and delegating to the correspondingview/beehub_YYY.php.