Commit Graph

12 Commits

Author SHA1 Message Date
Laurence Withers 83a5226e1a handler: drop sendfile(2) support
After some experimentation, I found that the sendfile(2) support did not
really save any time compared to just write(2) from an already
memory-mapped file.

After some reading, I think open/sendfile is supposed to be slightly
more efficient than open/mmap/write — but if we already did the mmap
step, then it doesn't save us much.

Moreover, the code to support sendfile(2) is a bit icky, and also forces
us to close the HTTP connection after serving a file.
2022-07-06 09:53:34 +01:00
Laurence Withers d5b4fcf0be Implement library support for Angular-style single page applications 2020-02-15 12:26:01 +00:00
Laurence Withers 7abc96d537 Moved module to src.lwithers.me.uk 2020-01-15 18:28:43 +00:00
Laurence Withers f7cd22f633 Single range support
We now support single part ranges, as per:

https://developer.mozilla.org/en-US/docs/Web/HTTP/Range_requests#Single_part_ranges

Multi-part ranges are not implemented because there have been far too
many bugs in this area.

It interacts with compression by selecting a byte range from the
compressed stream. Since the compressed stream is fixed, the results are
consistent.
2019-10-09 13:04:07 +01:00
Laurence Withers b7b5dd55d0 Remove stray debug printf 2019-07-17 16:30:20 +01:00
Laurence Withers c2d7bdaa71 handler: fix sendfile to be non-blocking
Having done a bit more research on exactly how to use sendfile()
effectively with Go's own event loop, we can now leave the HTTP socket
in non-blocking mode and correctly integrate with the event loop to wait
for the socket to be writeable once more.
2019-05-28 12:57:59 +01:00
Laurence Withers eac79eb605 Set blocking mode on hijacked fds for sendfile 2019-05-10 13:21:22 +01:00
Laurence Withers be86cbaed3 Handler: add SetIndex
This allows setting an index.html (or equivalent) filename; this means that
we can serve requests to "/foo" with the contents of "/foo/index.html".
2019-04-25 14:17:55 +01:00
Laurence Withers fdd1990e89 Reorganise ready to split into modules 2019-04-12 09:07:17 +01:00
Laurence Withers feb25bf276 Handler: close TCP conn after Sendfile
Since we hijacked the HTTP connection, we need to close the underlying TCP
connection after calling Sendfile.
2019-03-29 09:17:46 +00:00
Laurence Withers d42094ea72 Handler: call path.Clean first
Cope with things like /foo//bar by calling path.Clean before searching for
path in the map.
2019-03-29 09:17:15 +00:00
Laurence Withers 2a25d80249 Handler implementation
Currently missing range support, but compression and etag processing is
in along with basic header support. Still needs unit tests.
2019-03-08 09:16:38 +00:00