Changes between Version 14 and Version 15 of soc/2007/cgi


Ignore:
Timestamp:
May 22, 2008, 4:05:39 PM (14 years ago)
Author:
Darren Garvey
Comment:

Removing some glaring errors.

Legend:

Unmodified
Added
Removed
Modified
  • soc/2007/cgi

    v14 v15  
    11== About ==
     2
     3: Warning: This page may be out of date, see http://cgi.sf.net/doc for more up-to-date documentation.
    24
    35Below is a partial list of things this project aims to provide:
     
    2830  response resp; // make an empty response
    2931
    30   std::string name(req.GET("user_name"));
     32  std::string name(req[get]["user_name"]);
    3133  resp<< "Hello there, "
    3234      << (name.empty()? "stranger" : name)
    3335      << "!";
    34   resp.send(req.client());
    35  
    36   return 0;
     36
     37  return_(resp, req, 0); // send the response and `return 0;'
    3738}
    3839}}}
     
    5758  while(a.accept(req) == 0) // no error here
    5859  {
    59     std::string name(req.GET("user_name"));
     60    std::string name(req[get]["user_name"]);
    6061    resp<< "Hello there, "
    6162        << (name.empty()? "stranger" : name)
    6263        << "!";
     64
    6365    resp.send(req.client());
    64     req.close(http::ok);
    65     resp.clear();
     66    req.close(http::ok); // note: we can reuse the old request's memory now
     67    resp.clear();        // note: we can reuse the old response's memory now
    6668  }
    6769
     
    140142
    141143  resp<< "Hello, "
    142       << req.form("user_name") // this accepts either GET or POST variables.
     144      << req[form]["user_name"] // this checks either GET or POST variables.
    143145      << "!";
    144   resp.send(req.client());
    145 
    146   return req.close(http::ok); // we have to explicitly close the requests now.
     146 
     147  return_(resp, req, 0);
    147148}
    148149
     
    170171'''Separation of ```cgi::request``` and ```cgi::response```''':
    171172
    172 This separation is only a recent change. The main reasoning is that equivalent meta-data exists for both the request and the response (ie. same identifier, different value). Using getters/setters is one idea, although in a large program, there could be a situation where you set a response header and then need to check it later. If everything was done with the ```request``` object then there'd be no clean way to achieve this.
     173The original reasoning for this is that equivalent meta-data exists for both the request and the response (ie. same identifier, different value). Using getters/setters is one idea, although in a large program, there could be a situation where you set a response header and then need to check it later. If everything was done with the ```request``` object then there'd be no clean way to achieve this.
    173174
    174175Having two objects has other advantages:
     
    182183== Main Classes ==
    183184
    184 === ```cgi::basic_request<>``` ===
    185 This holds the data corresponding to the request. It will be specific to a Protocol type and will be aware of how to receive, send and parse data for that Protocol. There will be ```typedef```s for typical usage.
    186 
    187 === ```cgi::request``` ===
    188 By default, this provides a general (as opposed to generic) access point to any type of request. If constructed with a service object, then the request takes a request from the queue (or blocks until one is available). Default construction initialises a standard cgi environment.
    189 
    190 This generality is achieved using runtime linkage in a similar way to boost::any, although static linking can be forced using a choice of macros which turn ```cgi::request``` into a ```typedef``` for a particular ```cgi::basic_request<>```.
    191 
    192 === ```cgi::response``` ===
     185=== ```cgi::common::basic_request<>``` ===
     186This holds the data corresponding to the request. It will be specific to a Protocol type and will be aware of how to receive, send and parse data for that Protocol. There will be ```typedef```s for typical usage. (ie. ```cgi::request, acgi::request, fcgi::request```).
     187
     188=== ```cgi::common::response``` ===
    193189This simply holds headers and the content of the response and provides various ways to write to it. Up until it is sent to the user, it is unaware of what it's a response to. This helps keep both library and user code clean and explicit, without being overly verbose and aids significantly with response caching (something this library won't address for now).
    194190
     
    196192
    197193=== ```cgi::session``` ===
    198 This will provide simple session data caching.
    199 
    200 === ```cgi::basic_protocol_service<>``` ===
     194
     195This will provide simple session data caching. NOT YET!
     196
     197=== ```cgi::common::basic_protocol_service<>``` ===
    201198This is the base class in the library. It is a container for the `io_service`s (from Boost.Asio) that implement asynchronous support and holds lists of current connections and of waiting requests from multiplexed connections.
    202199
    203200== Important Internal Classes ==
    204201
    205 === ```cgi::basic_client<>``` ===
     202=== ```cgi::common::basic_client<>``` ===
    206203The gateway is the abstraction of the interface with the server. This can vary from just an abstraction of std::cin/cout to a fully multiplexed set of connections, which can themselves be of more than one type.
    207204
    208 === ```cgi::basic_request_acceptor<>``` ===
     205=== ```cgi::common::basic_request_acceptor<>``` ===
    209206Accepts a new, possibly unloaded request. Before using the request `cgi::basic_request<>::load()` or `cgi::basic_request<>::async_load()` '''must''' be called.
    210207