iron / staticfile

Static file-serving middleware for the Iron web framework.
MIT License
63 stars 56 forks source link

The `doc_server` example doesn't appear to work and has a few issues. #80

Closed nelsonjchen closed 8 years ago

nelsonjchen commented 8 years ago

https://github.com/iron/staticfile/blob/2ac0d6048415bb9e9f4ae169248225df8cb1996b/examples/doc_server.rs#L7

For starters, I'm not sure why we should run cargo test to run an example.

Second, the doc_server binary would not be generated from these instructions. Perhaps we meant to say cargo run --example doc_server? Was --example introduced after this example?

That said, the "doesn't appear to work" comes from the last instruction, "point your browser to http://127.0.0.1:3000/doc/". If I do that, I get a blank page. I get this from cURL request to that endpoint.

$ curl -vvv http://localhost:3000/doc/                                                                           
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 3000 (#0)
> GET /doc/ HTTP/1.1
> Host: localhost:3000
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Date: Thu, 28 Jul 2016 08:12:41 GMT
< Content-Length: 0
<
* Connection #0 to host localhost left intact

I do get the COPYRIGHT.txt and any other content below the / route like http://127.0.0.1:3000/COPYRIGHT.txt, but the docand src appear to end with 404s. Am I doing something wrong?

Hoverbear commented 8 years ago

According to git blame line 7 hasn't been added since sept 2014, so definitely. :)

I'm looking into this.

Hoverbear commented 8 years ago

Hey! I'm afraid I'm not having that problem. Here's what I did:

cargo doc && cargo run --example doc_server

Then I browsed to localhost:3000 and got this:

example

Can you please confirm you're experiencing something different? Can you tell me your rustc version, and your operating system?

Hoverbear commented 8 years ago

7346d72b6120a2f71e6dc6a46c53e79baf1ef7b0 fixed the example commands.

nelsonjchen commented 8 years ago

rustc 1.10.0 (cfcb716cf 2016-07-03)

OS X 10.11.6.

Case Insensitive HFS+

Hoverbear commented 8 years ago

Ahh I'm on rustc 1.12.0-nightly (936bfea94 2016-07-20). I'll try an older version...

nelsonjchen commented 8 years ago

I can try a newer version too.

Hoverbear commented 8 years ago

rustc 1.10.0 (cfcb716cf 2016-07-03) seems to work as well. I'm on Linux, do you know anyone who can test on OS X?

Are you testing this on master? I wonder if #81 is causing this for you.

nelsonjchen commented 8 years ago

I am indeed testing on master.

Hoverbear commented 8 years ago

@nelsonjchen Can you confirm the router example is also not working for you?

nelsonjchen commented 8 years ago

It works. The hello route works and ,πŸ˜†, the off by one letter static file mount route "docs" also appears to work.

nelsonjchen commented 8 years ago

Hold on, that's with this rust version.

rustc 1.12.0-nightly (feeca9457 2016-07-26)

nelsonjchen commented 8 years ago

πŸ˜• . Odd, now things seem to work, at least on this MacBook.

I could have sworn I was doing cargo doc --open and seeing docs and then wondering what's happening with staticfile's doc_server. I still have another Macbook with the same symptom, but it's a few miles away and a few hours away in schedule for me to get to.

nelsonjchen commented 8 years ago

That is with rustc 1.10.0 (cfcb716cf 2016-07-03). Just works. πŸ˜– . I'll close this for now. I'm like 80% sure I'm doing something stupid here. If I can still reproduce it on that other MacBook, I'll be sure to comment.

nelsonjchen commented 8 years ago

I left the lid open and I was able to remote into the other Macbook.

I was able to reproduce this issue. I checked I was running the current stable. I ran cargo doc and I got no output, so I guess it was up-to-date. I ran cargo run --example doc_server. I checked that I was accessing http://127.0.0.1/doc/, without the "s". I still got a blank page. I ran cargo doc --open and got the docs. I moved this local repository away.

I made another clone of the repository and repeated the steps but this time when I visited "http://127.0.0.1/doc/", it worked! πŸ˜–

I guess something bad compilation artifacts were affecting things. Maybe I just ran the example at a bad time and kept on building it with the "bad time"'s Lockfile where some dependency broke for a few moments. That would explain why things are working now.

Hmm... I just confirmed it. It was just that. When I use this Cargo.lock, doc_server results in a blank page. Here's the lockfile.

https://gist.github.com/nelsonjchen/a7707b9cfac1acb4c8b61748e4087e42

@Hoverbear , thank you for your help!

nelsonjchen commented 8 years ago

Having done a diff, I guess 0.2.1 of iron/mount fixed my issue. πŸ˜„

Hoverbear commented 8 years ago

Ahhh ha! Glad we caught it!