1*86d7f5d3SJohn Marino.\" 2*86d7f5d3SJohn Marino.\" Copyright (c) 2000 Alfred Perlstein 3*86d7f5d3SJohn Marino.\" 4*86d7f5d3SJohn Marino.\" All rights reserved. 5*86d7f5d3SJohn Marino.\" 6*86d7f5d3SJohn Marino.\" Redistribution and use in source and binary forms, with or without 7*86d7f5d3SJohn Marino.\" modification, are permitted provided that the following conditions 8*86d7f5d3SJohn Marino.\" are met: 9*86d7f5d3SJohn Marino.\" 1. Redistributions of source code must retain the above copyright 10*86d7f5d3SJohn Marino.\" notice, this list of conditions and the following disclaimer. 11*86d7f5d3SJohn Marino.\" 2. Redistributions in binary form must reproduce the above copyright 12*86d7f5d3SJohn Marino.\" notice, this list of conditions and the following disclaimer in the 13*86d7f5d3SJohn Marino.\" documentation and/or other materials provided with the distribution. 14*86d7f5d3SJohn Marino.\" 15*86d7f5d3SJohn Marino.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR 16*86d7f5d3SJohn Marino.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17*86d7f5d3SJohn Marino.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18*86d7f5d3SJohn Marino.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, 19*86d7f5d3SJohn Marino.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20*86d7f5d3SJohn Marino.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21*86d7f5d3SJohn Marino.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22*86d7f5d3SJohn Marino.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23*86d7f5d3SJohn Marino.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24*86d7f5d3SJohn Marino.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25*86d7f5d3SJohn Marino.\" 26*86d7f5d3SJohn Marino.\" $FreeBSD: src/share/man/man9/accf_http.9,v 1.1.2.6 2002/07/02 01:03:59 brian Exp $ 27*86d7f5d3SJohn Marino.\" 28*86d7f5d3SJohn Marino.Dd November 15, 2000 29*86d7f5d3SJohn Marino.Dt ACCF_HTTP 9 30*86d7f5d3SJohn Marino.Os 31*86d7f5d3SJohn Marino.Sh NAME 32*86d7f5d3SJohn Marino.Nm accf_http 33*86d7f5d3SJohn Marino.Nd "buffer incoming connections until a certain complete HTTP requests arrive" 34*86d7f5d3SJohn Marino.Sh SYNOPSIS 35*86d7f5d3SJohn Marino.Cd options INET 36*86d7f5d3SJohn Marino.Cd options ACCEPT_FILTER_HTTP 37*86d7f5d3SJohn Marino.Li kldload accf_http 38*86d7f5d3SJohn Marino.Sh DESCRIPTION 39*86d7f5d3SJohn MarinoThis is a filter to be placed on a socket that will be using 40*86d7f5d3SJohn Marino.Fn accept 41*86d7f5d3SJohn Marinoto receive incoming HTTP connections. 42*86d7f5d3SJohn Marino.Pp 43*86d7f5d3SJohn MarinoIt prevents the application from receiving the connected descriptor via 44*86d7f5d3SJohn Marino.Fn accept 45*86d7f5d3SJohn Marinountil either a full HTTP/1.0 or HTTP/1.1 HEAD or GET request has 46*86d7f5d3SJohn Marinobeen buffered by the kernel. 47*86d7f5d3SJohn Marino.Pp 48*86d7f5d3SJohn MarinoIf something other than a HTTP/1.0 or 49*86d7f5d3SJohn MarinoHTTP/1.1 HEAD or GET request is received the kernel will 50*86d7f5d3SJohn Marinoallow the application to receive the connection descriptor 51*86d7f5d3SJohn Marinovia 52*86d7f5d3SJohn Marino.Fn accept . 53*86d7f5d3SJohn Marino.Pp 54*86d7f5d3SJohn MarinoThe utility of 55*86d7f5d3SJohn Marino.Nm 56*86d7f5d3SJohn Marinois such that a server will not have to context switch several times 57*86d7f5d3SJohn Marinobefore performing the initial parsing of the request. 58*86d7f5d3SJohn MarinoThis effectively reduces the amount of required CPU utilization 59*86d7f5d3SJohn Marinoto handle incoming requests by keeping active 60*86d7f5d3SJohn Marinoprocesses in preforking servers such as Apache low 61*86d7f5d3SJohn Marinoand reducing the size of the filedescriptor set that needs 62*86d7f5d3SJohn Marinoto be managed by interfaces such as 63*86d7f5d3SJohn Marino.Fn select , 64*86d7f5d3SJohn Marino.Fn poll 65*86d7f5d3SJohn Marinoor 66*86d7f5d3SJohn Marino.Fn kevent 67*86d7f5d3SJohn Marinobased servers. 68*86d7f5d3SJohn Marino.Pp 69*86d7f5d3SJohn MarinoThe 70*86d7f5d3SJohn Marino.Nm 71*86d7f5d3SJohn Marinokernel option is also a module that can be enabled at runtime via 72*86d7f5d3SJohn Marino.Xr kldload 8 73*86d7f5d3SJohn Marinoif the INET option has been compiled into the kernel. 74*86d7f5d3SJohn Marino.Sh EXAMPLES 75*86d7f5d3SJohn MarinoAssuming ACCEPT_FILTER_HTTP has been included in the kernel config 76*86d7f5d3SJohn Marinofile or the 77*86d7f5d3SJohn Marino.Nm 78*86d7f5d3SJohn Marinomodule has been loaded, this will enable the http accept filter 79*86d7f5d3SJohn Marinoon the socket 80*86d7f5d3SJohn Marino.Fa sok . 81*86d7f5d3SJohn Marino.Bd -literal -offset 0i 82*86d7f5d3SJohn Marino struct accept_filter_arg afa; 83*86d7f5d3SJohn Marino 84*86d7f5d3SJohn Marino bzero(&afa, sizeof(afa)); 85*86d7f5d3SJohn Marino strcpy(afa.af_name, "httpready"); 86*86d7f5d3SJohn Marino setsockopt(sok, SOL_SOCKET, SO_ACCEPTFILTER, &afa, sizeof(afa)); 87*86d7f5d3SJohn Marino.Ed 88*86d7f5d3SJohn Marino.Sh SEE ALSO 89*86d7f5d3SJohn Marino.Xr setsockopt 2 , 90*86d7f5d3SJohn Marino.Xr accept_filter 9 91*86d7f5d3SJohn Marino.Sh HISTORY 92*86d7f5d3SJohn MarinoThe accept filter mechanism and the 93*86d7f5d3SJohn Marino.Nm 94*86d7f5d3SJohn Marinofilter were introduced in 95*86d7f5d3SJohn Marino.Fx 4.0 . 96*86d7f5d3SJohn Marino.Sh AUTHORS 97*86d7f5d3SJohn MarinoThis manual page and the filter were written by 98*86d7f5d3SJohn Marino.An Alfred Perlstein . 99