Merge branch 'master' into jwi-bcc64xsingletonwarning
[ACE_TAO.git] / ACE / apps / JAWS2 / HTTP_10_Parse.cpp
blobfe04efc0c512de8de13cec34fc9fd94db8d4a7b6
1 #include "HTTP_10.h"
3 #include "JAWS/JAWS.h"
4 #include "JAWS/IO.h"
5 #include "JAWS/IO_Handler.h"
6 #include "JAWS/Policy.h"
8 #include "HTTP_10_Request.h"
11 // --------------- PARSE TASK ----------------------
13 JAWS_HTTP_10_Parse_Task::JAWS_HTTP_10_Parse_Task ()
17 JAWS_HTTP_10_Parse_Task::~JAWS_HTTP_10_Parse_Task ()
21 int
22 JAWS_HTTP_10_Parse_Task::handle_put (JAWS_Data_Block *data, ACE_Time_Value *)
24 JAWS_TRACE ("JAWS_HTTP_10_Parse_Task::handle_put");
26 JAWS_IO_Handler *handler = data->io_handler ();
27 JAWS_Dispatch_Policy *policy = this->policy ();
28 if (policy == 0) policy = data->policy ();
29 JAWS_IO *io = policy->io ();
31 JAWS_HTTP_10_Request *info;
33 if (data->payload ())
34 info = reinterpret_cast<JAWS_HTTP_10_Request *> (data->payload ());
35 else
37 info = new JAWS_HTTP_10_Request;
38 if (info == 0)
40 ACE_ERROR ((LM_ERROR, "%p\n", "JAWS_HTTP_10_Parse_Task::handle_put"));
41 return -1;
43 data->payload (static_cast<void *> (info));
46 while (info->receive (*(ACE_Message_Block *)data) == 0)
48 int next_read_size = data->space ();
50 if (next_read_size == 0)
52 // Set payload to reflect "request too long"
53 break;
56 io->read (handler, data, next_read_size);
57 switch (handler->status ())
59 case JAWS_IO_Handler::READ_OK:
60 // Behaved synchronously, reiterate
61 continue;
62 case JAWS_IO_Handler::READ_ERROR:
63 case JAWS_IO_Handler::READ_ERROR_A:
64 return -1;
65 default:
66 // This needs to be a value that tells the framework that
67 // the call is asynchronous, but that we should remain in
68 // the current task state.
69 return 2;
73 // request completely parsed
74 info->dump ();
76 return 0;