Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / ACE / apps / JAWS2 / HTTP_10_Parse.cpp
blob5e137cf6d4b979f77784393d0fc4aa4b0555d354
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"
12 // --------------- PARSE TASK ----------------------
14 JAWS_HTTP_10_Parse_Task::JAWS_HTTP_10_Parse_Task (void)
18 JAWS_HTTP_10_Parse_Task::~JAWS_HTTP_10_Parse_Task (void)
22 int
23 JAWS_HTTP_10_Parse_Task::handle_put (JAWS_Data_Block *data, ACE_Time_Value *)
25 JAWS_TRACE ("JAWS_HTTP_10_Parse_Task::handle_put");
27 JAWS_IO_Handler *handler = data->io_handler ();
28 JAWS_Dispatch_Policy *policy = this->policy ();
29 if (policy == 0) policy = data->policy ();
30 JAWS_IO *io = policy->io ();
32 JAWS_HTTP_10_Request *info;
34 if (data->payload ())
35 info = reinterpret_cast<JAWS_HTTP_10_Request *> (data->payload ());
36 else
38 info = new JAWS_HTTP_10_Request;
39 if (info == 0)
41 ACE_ERROR ((LM_ERROR, "%p\n", "JAWS_HTTP_10_Parse_Task::handle_put"));
42 return -1;
44 data->payload (static_cast<void *> (info));
47 while (info->receive (*(ACE_Message_Block *)data) == 0)
49 int next_read_size = data->space ();
51 if (next_read_size == 0)
53 // Set payload to reflect "request too long"
54 break;
57 io->read (handler, data, next_read_size);
58 switch (handler->status ())
60 case JAWS_IO_Handler::READ_OK:
61 // Behaved synchronously, reiterate
62 continue;
63 case JAWS_IO_Handler::READ_ERROR:
64 case JAWS_IO_Handler::READ_ERROR_A:
65 return -1;
66 default:
67 // This needs to be a value that tells the framework that
68 // the call is asynchronous, but that we should remain in
69 // the current task state.
70 return 2;
74 // request completely parsed
75 info->dump ();
77 return 0;