00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 #include "AllowNothingService.hpp"
00011 #include <pion/config.hpp>
00012 #include <pion/http/response_writer.hpp>
00013 
00014 using namespace pion;
00015 
00016 namespace pion {        
00017 namespace plugins {     
00018 
00019     
00020 void AllowNothingService::operator()(http::request_ptr& http_request_ptr, tcp::connection_ptr& tcp_conn)
00021 {
00022     static const std::string DENY_HTML = "<html><body>No, you can't.</body></html>";
00023     http::response_writer_ptr writer(http::response_writer::create(tcp_conn, *http_request_ptr,
00024                                                             boost::bind(&tcp::connection::finish, tcp_conn)));
00025     writer->get_response().set_status_code(http::types::RESPONSE_CODE_METHOD_NOT_ALLOWED);
00026     writer->get_response().set_status_message(http::types::RESPONSE_MESSAGE_METHOD_NOT_ALLOWED);
00027 
00028     
00029     
00030 
00031     
00032     writer->get_response().add_header("Allow", "GET");
00033 
00034     writer->write_no_copy(DENY_HTML);
00035     writer->write_no_copy(http::types::STRING_CRLF);
00036     writer->write_no_copy(http::types::STRING_CRLF);
00037     writer->send();
00038 }
00039 
00040     
00041 }   
00042 }   
00043 
00044 
00046 extern "C" PION_PLUGIN pion::plugins::AllowNothingService *pion_create_AllowNothingService(void)
00047 {
00048     return new pion::plugins::AllowNothingService();
00049 }
00050 
00052 extern "C" PION_PLUGIN void pion_destroy_AllowNothingService(pion::plugins::AllowNothingService *service_ptr)
00053 {
00054     delete service_ptr;
00055 }