Skip to content

Instantly share code, notes, and snippets.

@postwait
Created September 2, 2011 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save postwait/1189570 to your computer and use it in GitHub Desktop.
Save postwait/1189570 to your computer and use it in GitHub Desktop.

HTTP Accept Filters for Solaris

Once built and installed: (make install), you can load these with

 soconfig -F httpf httpf prog 2:2:0,2:2:6,26:2:0,26:2:6

Then applications must programatically enable them immediately after socket() and before bind() with a setsockopt() call as follows:

 setsockopt(fd, SOL_FILTER, FIL_ATTACH, "httpf", 6);

How they work?

This is a kernel module that use the sockfs filtering API. The accept notification is deferred for new passive sockets until:

  • 4 bytes are read that are not GET, HEAD, POST, PUT (trailing spaces where needed).
  • a \r\n\r\n or \n\n are found after the initial 4 bytes.
  • 8192 bytes are read
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment