Age | Commit message (Collapse) | Author |
|
|
|
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.
|
|
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.
|
|
|
|
The latest version of Conduit, 0.9.0-alpha.3, adds a new `path_mut`
method.
|
|
|
|
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.
|
|
Since we're only using it in an example binary, it shouldn't be a main
library dependency.
|
|
|
|
|
|
|
|
|
|
I was only using it to test the examples.
|
|
|
|
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
|
|
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.
|
|
Copy the short example from the module documentation into an executable
file.
|
|
Write doc comments for functions and types, and include a short example.
|
|
|
|
Reduce a few lines.
|
|
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.
|
|
|
|
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`.
|
|
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.
|
|
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.
|
|
Now that we have a `request` module, the "Request" part of the name is
redundant.
|
|
Add a new error type that we can use to collect and match errors from
`handle_request()`.
|
|
Make a separate function that can return a result to make it easier to
handle errors from the handler.
|
|
|
|
Turns out I didn't need to make it public as we only need to use it
within the module.
|
|
Want to separate request and server code.
|
|
Try making a server with more than one route.
|
|
|
|
|
|
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.
|
|
|
|
To match the struct field order.
|
|
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.
|
|
|
|
|
|
|
|
Seemed to make sense to add a new error type to group the parse errors
together.
|
|
|
|
|
|
Looks like we don't need to implement this hopefully.
|
|
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.
|
|
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
|
|
|
|
|
|
|