Return-Path: X-Original-To: apmail-httpd-modules-dev-archive@minotaur.apache.org Delivered-To: apmail-httpd-modules-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 03F2F1025F for ; Fri, 27 Sep 2013 07:00:49 +0000 (UTC) Received: (qmail 31482 invoked by uid 500); 27 Sep 2013 07:00:37 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 31439 invoked by uid 500); 27 Sep 2013 07:00:22 -0000 Mailing-List: contact modules-dev-help@httpd.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: modules-dev@httpd.apache.org Delivered-To: mailing list modules-dev@httpd.apache.org Received: (qmail 31407 invoked by uid 99); 27 Sep 2013 07:00:16 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Sep 2013 07:00:16 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of sorinm@gmail.com designates 74.125.82.54 as permitted sender) Received: from [74.125.82.54] (HELO mail-wg0-f54.google.com) (74.125.82.54) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Sep 2013 07:00:10 +0000 Received: by mail-wg0-f54.google.com with SMTP id m15so2230704wgh.33 for ; Thu, 26 Sep 2013 23:59:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=FVNfLinUvoGTUJ1kK+GVGQ1w7wibV94xke8Tanp5h6I=; b=JIWYo4tzbEe6+jcMCRIZX1/qxy5xkqxIXH+wdvXOMDqX1Jm+d1zhm3aYulujVvtE3X GnzQAgNRXVA7AwmV/Tu0Uzhj/OGhjnnfmaTTV7g7p8vDhWt8Yee4MHPU62UAgMTtqxZl 4+bgpKxbxKD9HqW8TzTBWAXGG1pfIhZ0X7PDuTvtY60y/punedJq1D7dZvY4LIKWjc+D MPgnStvBhMVMNUJ5CCk2hr2KVoIHl2st4C5wtMjGgiKbjsl5Bxexsay3FzT2BuQroUEW E02NYC5UQfyp2/+nG+Ao9jvc/CVKGlOC6IkOWVBc03oTfNtPWbj4a1IlxVY90ndavjlX +H0g== X-Received: by 10.180.198.79 with SMTP id ja15mr1280208wic.36.1380265189519; Thu, 26 Sep 2013 23:59:49 -0700 (PDT) Received: from ?IPv6:2a01:e35:8b73:8dd0:762f:68ff:fee5:8d8? ([2a01:e35:8b73:8dd0:762f:68ff:fee5:8d8]) by mx.google.com with ESMTPSA id ey4sm10857054wic.11.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 26 Sep 2013 23:59:48 -0700 (PDT) Message-ID: <52452CDF.3090906@gmail.com> Date: Fri, 27 Sep 2013 08:59:43 +0200 From: Sorin Manolache User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130821 Icedove/17.0.8 MIME-Version: 1.0 To: modules-dev@httpd.apache.org Subject: Re: response handling inside ap_hook_create_request cb function References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org On 2013-09-27 03:06, Pon Umapathy Kailash S wrote: > Hi, > Here is a quick background on what I am trying to do(basically adding > support for websockets - in a slightly customised manner as needed for > my app): > > - Handle the initial handshake inside a cb function registered as a > handler hook(from here, I compute checksums required and return the > response headers as needed). > Also, the socket from which the request was read is stored in a cache. > > - For subsequent message reception(on the same connection), i have a > function cb registered using ap_hook_create_request(since this is a > different protocol format message). Here, I read and parse the > messages/requests which are coming in from the cached list of > sockets(this is working). > > However, once I return from this cb, the connection/socket seems to be > closed. I guess the request is further passed down to hooks down the > line and the connection is closed since the req format is not known. > > What would be the best way to handle this scenario? > > I have the following in mind: > - let the request not be processed any further(and keep the connection on). > - create a req structure with dummy http headers that i can later > recognise and handle inside my handler hook to just ignore later on > > are there any examples/notes on how these can be achieved? In my opinion, it is too late to handle non-http in the create_request callback. The create_request callback is called from ap_run_process_connection->ap_process_http_{sync|async}_connection->ap_read_request. Your create_request callback returns to ap_read_request from where the request is further processed as an http request. In my opinion you should short-cut the http processing and hook ap_hook_process_connection. However, there, in process_connection, you have no request_rec, you have just a conn_rec. process_connection is called only once per connection creation. So it should handle all the requests that arrive while the connection is open. Sorin > > Regards, > Umapathy >