3 #include "JAWS/IO_Handler.h"
4 #include "JAWS/Policy.h"
8 #include "HTTP_10_Request.h"
11 // --------------- WRITE TASK ----------------------
13 JAWS_HTTP_10_Write_Task::JAWS_HTTP_10_Write_Task ()
17 JAWS_HTTP_10_Write_Task::~JAWS_HTTP_10_Write_Task ()
22 JAWS_HTTP_10_Write_Task::handle_put (JAWS_Data_Block
*data
, ACE_Time_Value
*)
24 JAWS_TRACE ("JAWS_HTTP_10_Write_Task::handle_put");
26 JAWS_IO_Handler
*handler
= data
->io_handler ();
28 JAWS_Dispatch_Policy
*policy
= this->policy ();
29 if (policy
== 0) policy
= data
->policy ();
31 JAWS_IO
*io
= policy
->io ();
33 JAWS_HTTP_10_Request
*info
= static_cast<JAWS_HTTP_10_Request
*> (data
->payload ());
35 if (info
->status () == (int) JAWS_HTTP_10_Request::STATUS_QUIT
)
43 ACE_DEBUG ((LM_DEBUG
, " (%t) request %s::%s::%s parsed\n",
44 (info
->method () ? info
->method () : "-"),
45 (info
->uri () ? info
->uri () : "="),
46 (info
->version () ? info
->version () : "HTTP/0.9")));
49 if (info
->type () != (int) JAWS_HTTP_10_Request::GET
)
50 info
->set_status (JAWS_HTTP_10_Request::STATUS_NOT_IMPLEMENTED
);
52 if (info
->type () == (int) JAWS_HTTP_10_Request::QUIT
)
53 info
->set_status (JAWS_HTTP_10_Request::STATUS_QUIT
);
55 if (info
->status () != (int) JAWS_HTTP_10_Request::STATUS_OK
)
57 JAWS_TRACE ("JAWS_HTTP_10_Write_Task::handle_put, ! STATUS OK");
60 "<html><head><title>HTTP/1.0 500 Internal Server Error</title>"
61 "<body><h1>Server Error</h1>HTTP/1.0 500 Internal Server Error"
64 io
->send_error_message (handler
, msg
, sizeof (msg
));
65 switch (handler
->status ())
67 case JAWS_IO_Handler::WRITE_OK
:
68 case JAWS_IO_Handler::WRITE_OK_A
:
69 if (info
->status () == (int) JAWS_HTTP_10_Request::STATUS_QUIT
)
80 case JAWS_IO_Handler::WRITE_ERROR
:
81 case JAWS_IO_Handler::WRITE_ERROR_A
:
94 if (ACE_OS::strcmp (info
->version (), "HTTP/0.9") == 0)
95 io
->transmit_file (handler
,
102 io
->transmit_file (handler
,
104 "HTTP/1.0 200 Ok\r\n\r\n",
109 switch (handler
->status ())
111 case JAWS_IO_Handler::TRANSMIT_OK_A
:
113 JAWS_TRACE ("JAWS_HTTP_10_Write_Task::handle_put, OK_A");
119 case JAWS_IO_Handler::TRANSMIT_OK
:
121 JAWS_TRACE ("JAWS_HTTP_10_Write_Task::handle_put, OK");
126 case JAWS_IO_Handler::TRANSMIT_ERROR
:
128 JAWS_TRACE ("JAWS_HTTP_10_Write_Task::handle_put, ERROR");
133 case JAWS_IO_Handler::TRANSMIT_ERROR_A
:
135 JAWS_TRACE ("JAWS_HTTP_10_Write_Task::handle_put, ERROR_A");
142 JAWS_TRACE ("JAWS_HTTP_10_Write_Task::handle_put, DEFAULT");