static int request_buffer_plugin(TSCont contp, TSEvent event, void *edata) { TSDebug(PLUGIN_NAME, "request_buffer_plugin starting, event[%d]", event); TSHttpTxn txnp = (TSHttpTxn)(edata); if (event == TS_EVENT_HTTP_REQUEST_BUFFER_COMPLETE) { int len = 0; char *body = request_body_get(txnp, &len); TSDebug(PLUGIN_NAME, "request_buffer_plugin gets the request body with length[%d]", len); TSfree(body); TSContDestroy(contp); } else { ink_assert(0); } TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE); return 0; }
int handle_read(int event, void *data) { int r; char *str; switch (event) { case VC_EVENT_READ_READY: r = reader->read_avail(); reader->read(&request[req_len], r); req_len += r; request[req_len] = 0; Debug("net_test", "%s\n", request); fflush(stdout); // vc->set_inactivity_timeout(HRTIME_SECONDS(30)); if (strcmp(&request[req_len - 4], "\r\n\r\n") == 0) { Debug("net_test", "The request header is :\n%s\n", request); // parse and get the doc size SET_HANDLER(&NetTesterSM::handle_write); ink_assert(doc_len == resp_reader->read_avail()); vc->do_io_write(this, doc_len, resp_reader); // vc->set_inactivity_timeout(HRTIME_SECONDS(10)); } break; case VC_EVENT_READ_COMPLETE: /* FALLSTHROUGH */ case VC_EVENT_EOS: r = reader->read_avail(); str = new char[r + 10]; reader->read(str, r); Debug("net_test", "%s", str); fflush(stdout); case VC_EVENT_ERROR: case VC_EVENT_INACTIVITY_TIMEOUT: vc->do_io_close(); // fixme // handle timeout events break; default: ink_release_assert(!"unknown event"); } return EVENT_CONT; }