about summary refs log tree commit homepage
path: root/lib/PublicInbox/HTTP.pm
DateCommit message (Collapse)
2016-04-06http: clarify intent for persistence
We don't actually need to know if a response is chunked or what the actual Content-Length is; we just need to know if the PSGI app properly terminated the response so we can handle persistent connections.
2016-04-04http: fix condition for detecting persistence
Oops, we need to watch out for how we handle operator precedence and ensure responses without a Content-Length or "Transfer-Encoding: chunked" header will always disconnect after writing.
2016-03-12http: use Plack::HTTPParser for HTTP parsing
This allows us to reduce installation dependencies while retaining performance as it favors HTTP::Parser::XS when it is installed and available. PLACK_HTTP_PARSER_PP may be set to 1 to force a pure Perl parser for testing.
2016-03-12http: prevent zero-byte writes
Plack::Middleware::Deflater (and perhaps other middleware) triggers zero-byte writes which wastes syscalls when they get passed to Danga::Socket. This may also trigger problems when we introduce TLS support in the future.
2016-03-06http: reject excessively large HTTP request bodies
We cannot risk using all of a users' disk space buffering gigantic requests. Use the defaults git gives us since we primarily host git repositories.
2016-03-06http: ensure errors are printable before PSGI env
We cannot rely on a client socket having a PSGI env before headers are fully-parsed as we seek to avoid storing hashes for idle clients. Sso print errors to the psgi.errors value which belongs to the httpd listener, instead.
2016-03-06http: reject excessive headers
HTTP::Parser::XS::PP does not reject excessively large headers like the XS version. Ensure we reject headers over 16K since public-inbox should never need such large request headers.
2016-03-03daemon: introduce host_with_port for identifying sockets
This allows us to share more code between daemons and avoids having to make additional syscalls for preparing REMOTE_HOST and REMOTE_PORT in the PSGI env in -httpd. This will also make supporting HTTP (and NNTP) over Unix sockets easier in a future commit.
2016-03-01http: better error handling for EMFILE/ENFILE
Better to throw the error back to the client ASAP if we're out-of-descriptors. We will need to implement idle client expiration for long-lived HTTP connections.
2016-02-29favor procedural calls for most private functions
This makes for better compile-time checking and also helps document which calls are private for HTTP and NNTP. While we're at it, use IO::Handle::* functions procedurally, too, since we know we're working with native glob handles.
2016-02-29http: avoid needless time2str calls
Checking the time is nearly free on modern systems with vDSO/vsyscall/similar while sprintf is always expensive.
2016-02-29http: document event_write usage
It may not be obvious where we are when we enter the event_write callback. Hopefully this clarifies things.
2016-02-29http: error check for sysseek on input
Just in case we screwed up somewhere, we need to match up syswrite to sysseek and we also favor procedural calls for native types.
2016-02-28http: support graceful shutdown like nntp
HTTP responses may be long-running or requests may be slow or pipelined. Ensure we don't kill them off prematurely.
2016-02-27http: simplify offset calculation slightly
No point in comparing an empty string; length() is only potentially expensive on big strings.
2016-02-25httpd: fill in missing Danga::Socket callbacks
Danga::Socket will die on us if we hit the base implementations.
2016-02-23initial public-inbox-httpd implemenation
This is meant to provide an easy starting point for server admins. It provides a basic HTTP server for admins unfamiliar with configuring PSGI applications as well as being an identical interface for management as our nntpd implementation. This HTTP server may also be a generic Plack/PSGI server for existing Plack/PSGI applications.