aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2020-07-18Increase version v0.2.0 -> v0.2.1HEADv0.2.1masterTeddy Wing
2020-07-18FastCgiRequest::path: Get path from `REQUEST_URI`Teddy Wing
Use the `REQUEST_URI` param instead of `SCRIPT_NAME` to get the request path. Using `SCRIPT_NAME` caused issues with redirects. If my FastCGI program has the file name `script.fcgi`, and I set up a redirect from `/script` to `/script.fcgi`, then `path()` should return `/script` when using that path. In the above case, because we were using the `SCRIPT_NAME` param, `path()` would return `/script.fcgi` instead. This caused routes defined with a `RouteBuilder` to not match correctly. Now that we're using `REQUEST_URI`, we need to trim the query string and hash, which are included in the param value, since we only want the URI path.
2020-07-18server.rs: Remove canonical status name from "Status" headerTeddy Wing
This seemed to cause the name to be doubled in the final Apache HTTP header. Since it could cause that issue and is not necessary, we can remove it.
2020-07-17Increase version v0.1.1 -> v0.2.0v0.2.0Teddy Wing
2020-07-17FastCgiRequest: Implement `conduit::RequestExt::path_mut`Teddy Wing
The latest version of Conduit, 0.9.0-alpha.3, adds a new `path_mut` method.
2020-07-16Increase version v0.1.0 -> v0.1.1v0.1.1Teddy Wing
2020-07-16server.rs: Fix HTTP status code headerTeddy Wing
I was getting persistent 500 errors on Apache with mod_fastcgi: FastCGI: comm with server "/Applications/MAMP/htdocs/test.fcgi" aborted: error parsing headers: malformed header 'HTTP/1.1 200 OK' Forgot that you need to use a "Status" header for FastCGI to set the HTTP status code, like: Status: 404 This isn't an HTTP server. Apparently knew this at one point for the DomeKey web site, but completely forgot. Thanks to Ole (https://stackoverflow.com/users/312098/ole) and RichieHindle (https://stackoverflow.com/users/21886/richiehindle) on Stack Overflow for this question and answer that helped me figure it out: https://stackoverflow.com/questions/11223166/malformed-header-from-script-bad-header-http-1-1-302-found Didn't notice this previously as I was using Lighttpd for testing, and its FastCGI module must be more forgiving.
2020-07-04Cargo.toml: Move `conduit-router` to `dev-dependencies`v0.1.0Teddy Wing
Since we're only using it in an example binary, it shouldn't be a main library dependency.
2020-07-04Add READMETeddy Wing
2020-07-04Script to generate docs to a GitHub pages branchTeddy Wing
2020-07-04Increase version v0.0.1 -> v0.1.0Teddy Wing
2020-07-04Add license (GNU GPLv3+)Teddy Wing
2020-07-04Move `lighttpd.conf` to `examples/`Teddy Wing
I was only using it to test the examples.
2020-07-04examples/server.rs: Remove unused imports and variableTeddy Wing
2020-07-04Server::start: Return a `Server` directly instead of a `Result`Teddy Wing
We don't have any `Result`s to propagate in this function, so the `Result` return wrapper is unnecessary. Must have copied this signature from Civet without thinking: https://github.com/conduit-rust/rust-civet/blob/ab9c52ca634f65439060c2248295d2ac354aead5/src/lib.rs#L214
2020-07-04request::Error: Remove context from error variantsTeddy Wing
Since we don't need to add any additional context or messages here, we can turn off error context for these variants and shorten error propagation.
2020-07-04Add examples/small.rsTeddy Wing
Copy the short example from the module documentation into an executable file.
2020-07-04Add documentationTeddy Wing
Write doc comments for functions and types, and include a short example.
2020-07-04Merge branch 'conduit'Teddy Wing
2020-07-04server::internal_server_error: Change `match` to `unwrap_or_else`Teddy Wing
Reduce a few lines.
2020-07-04server: Log errorsTeddy Wing
Provide a mechanism to get detailed error messages when 500 internal server errors happen. We don't want to expose any detailed error information to clients, but it would be useful for administrators to know the cause of any errors.
2020-07-04server::handle_request: Wrap linesTeddy Wing
2020-07-04server: Rename `Error::WriteError` to `Error::Write` and remove contextTeddy Wing
Since we don't actually need any additional context here, we can remove it. Since that allows us to avoid calling `context()` with the `WriteError` context selector, we can then safely rename `WriteError` to `Write`.
2020-07-04server: Rename `Error::Io` to `Error::WriteError`Teddy Wing
Make this specifically about errors writing instead of a generic I/O error. Name the variant `WriteError` instead of `Write` because Snafu will generate context selector structs with these names and we already have a `Write` identifier imported.
2020-07-04Server::start: Handle errors with a 500 responseTeddy Wing
If we get errors building the request or Conduit errors, respond with a 500 error. Otherwise, it's a write error, and we should do nothing (ideally log the error), because this means the client closed the connection or there are bigger problems.
2020-06-29Rename `request::RequestError` to `request::Error`Teddy Wing
Now that we have a `request` module, the "Request" part of the name is redundant.
2020-06-29server::handle_request: Return errorsTeddy Wing
Add a new error type that we can use to collect and match errors from `handle_request()`.
2020-06-29Server::start: Extract `fastcgi::run` request handler to functionTeddy Wing
Make a separate function that can return a result to make it easier to handle errors from the handler.
2020-06-29Move `Server` code into a `server.rs` moduleTeddy Wing
2020-06-29FastCgiRequest: Make `scheme()` method privateTeddy Wing
Turns out I didn't need to make it public as we only need to use it within the module.
2020-06-29Move request code to `request.rs`Teddy Wing
Want to separate request and server code.
2020-06-28examples/server: Try using a `conduit_router::RouteBuilder`Teddy Wing
Try making a server with more than one route.
2020-06-28Server::start: Implement `conduit::Body::File` responseTeddy Wing
2020-06-28Server::start(): Write HTTP version and status codeTeddy Wing
2020-06-28Server: Working `start()` implementationTeddy Wing
Got a draft version of the server working. Change the example to use the new Conduit server. Got a working HTML fragment response. Need to handle `conduit::Body::File` as well as unwrapped errors.
2020-06-28FastCgiRequest::new: Remove unnecessary variableTeddy Wing
2020-06-28FastCgiRequest: Reorder `host` method implementationTeddy Wing
To match the struct field order.
2020-06-28FastCgiRequest: Implement `conduit::RequestExt` `body` methodTeddy Wing
Needed to change some things around to be able to use a mutable borrow for the `fastcgi::Stdin` body and an immutable borrow of `request` for all the other fields. Passed `fastcgi::Stdin` over through a `Read` implementation, because returning `&mut self.request.stdin()` was impossible, since the caller owns the `fastcgi::Stdin` reference.
2020-06-28FastCgiRequest: Add empty extensions map to implsTeddy Wing
2020-06-28FastCgiRequest: Add headers to `conduit::RequestExt`Teddy Wing
2020-06-28FastCgiRequest: Add content lengthTeddy Wing
2020-06-28FastCgiRequest: Add remote addrTeddy Wing
Seemed to make sense to add a new error type to group the parse errors together.
2020-06-27FastCgiRequest: Add query stringTeddy Wing
2020-06-27FastCgiRequest: Add request pathTeddy Wing
2020-06-27FastCgiRequest: Use a `None` `virtual_root`Teddy Wing
Looks like we don't need to implement this hopefully.
2020-06-27FastCgiRequest: Remove elidable `'b` lifetime in `conduit::RequestExt`Teddy Wing
Turns out I don't need this `'b` lifetime in the `conduit::RequestExt` `impl`. I had just assumed it was necessary because I copied it as `'a` from the "missing trait methods" error message.
2020-06-27FastCgiRequest: Start implementing `conduit::RequestExt`Teddy Wing
Was getting this error about the lifetimes in the trait impl: error[E0308]: method not compatible with trait --> src/lib.rs:137:4 | 137 | fn host(&'a self) -> conduit::Host<'a> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch | = note: expected fn pointer `fn(&'a FastCgiRequest<'static>) -> conduit::Host<'a>` found fn pointer `fn(&'a FastCgiRequest<'static>) -> conduit::Host<'a>` note: the lifetime `'a` as defined on the method body at 137:4... --> src/lib.rs:137:4 | 137 | fn host(&'a self) -> conduit::Host<'a> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: ...does not necessarily outlive the lifetime `'a` as defined on the impl at 124:6 --> src/lib.rs:124:6 | 124 | impl<'a> conduit::RequestExt for FastCgiRequest { | ^^ error[E0308]: method not compatible with trait --> src/lib.rs:137:4 | 137 | fn host(&'a self) -> conduit::Host<'a> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch | = note: expected fn pointer `fn(&'a FastCgiRequest<'static>) -> conduit::Host<'a>` found fn pointer `fn(&'a FastCgiRequest<'static>) -> conduit::Host<'a>` note: the lifetime `'a` as defined on the impl at 124:6... --> src/lib.rs:124:6 | 124 | impl<'a> conduit::RequestExt for FastCgiRequest { | ^^ note: ...does not necessarily outlive the lifetime `'a` as defined on the method body at 137:4 --> src/lib.rs:137:4 | 137 | fn host(&'a self) -> conduit::Host<'a> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Learned from these resources that the problem arose because the `impl` uses an `'a` lifetime, but the lifetime on the `host()` method need to be a different one: https://github.com/rust-lang/rust/issues/56423 https://stackoverflow.com/questions/24847331/rust-lifetime-error-expected-concrete-lifetime-but-found-bound-lifetime/24848424#24848424
2020-06-27FastCgiRequest: Add HTTP hostTeddy Wing
2020-06-27FastCgiRequest: Add `conduit::Scheme`Teddy Wing
2020-06-27FastCgiRequest: Add `conduit::Version`Teddy Wing