asmttpd icon indicating copy to clipboard operation
asmttpd copied to clipboard

Added basic directory listing fixing #32. Added 301 responses.

Open triforce opened this issue 6 years ago • 14 comments

  • Extended thread buffer by 2048
  • Added a very basic HTML formatted response with a list of the directory contents
  • When request for a directory is a non forward slash terminated request a 301 is sent to the client, triggering their browser to request a forward slash terminated request.

triforce avatar Nov 03 '17 09:11 triforce

@nemasu please test this thoroughly if you have a chance.

triforce avatar Nov 03 '17 09:11 triforce

This looks great! I will start testing it shortly.

nemasu avatar Nov 08 '17 05:11 nemasu

Sorry for the delay, I got around to testing it a bit.

I ran into a problem when I did something like this: cd web_root; mkdir dir1; touch dir1/{a,b,c}

If I go to localhost/dir1 the listing works, but when I click on one of them, it tries to go to localhost/dir1/a/ and then 404s instead of downloading a.

nemasu avatar Nov 20 '17 00:11 nemasu

It think's 'a' is a directory for some reason. I will look into it.

triforce avatar Nov 21 '17 09:11 triforce

Could you retest please @nemasu? It turned out to be quite a simple fix in the end!

triforce avatar Dec 05 '17 09:12 triforce

Hello, sorry for the super late reply. I did some retesting, seems to be working so far!

There's 2 potential things though: -Putting the previous directory ("...") at the top of the list. -If 'index.html' exists in a directory, display that as default.

What do you think?

nemasu avatar Jan 17 '18 04:01 nemasu

Yes sounds fine to me. So presumably when in the web_root there would be no previous directory link shown? Other web servers have directory listing as a config option as well so perhaps we should start planning a way to turn features on and off after this?

triforce avatar Jan 19 '18 11:01 triforce

Yeah that makes sense. Funny you should mention config options, I was just thinking about how to go about disabling features to reduce binary size.

nemasu avatar Jan 23 '18 02:01 nemasu

To make thing easier though, I think we should do optional features as a separate issue after merging the directory code.

nemasu avatar Jan 24 '18 01:01 nemasu

Yep makes sense.

triforce avatar Jan 24 '18 11:01 triforce

@nemasu feel free to make those changes, I haven't had time recently unfortunately.

triforce avatar Oct 03 '18 09:10 triforce

Okay, I'll see if I can.

nemasu avatar Oct 04 '18 08:10 nemasu

This is teetering on the edge of being finished @nemasu. There is just these two issues which you raised outstanding:

-Putting the previous directory ("...") at the top of the list. -If 'index.html' exists in a directory, display that as default.

If anyone has some time then feel free to jump in and implement those two issues.

triforce avatar Apr 17 '19 13:04 triforce

@nemasu after studying the code more closely it looks like requests to the root directory (and nothing else) adds the default document (index.html), so as part of the outstanding changes still required here we should remove that logic and integrate it with the directory listing functionality.

triforce avatar Feb 13 '20 11:02 triforce

Hello @triforce, I'm finally looking at getting this committed, there are merge conflicts however since it's been ... a while, to say the least (sorry about that).

I've made your changes into a patch file relative to the current HEAD, if you like, you can close this PR and make a new one with the updated patch, and I'll accept it and work on the additions after. Of course, if you want, you can use this PR too, I just don't really know an easy way to do that.

directory_support.patch

nemasu avatar Apr 09 '23 04:04 nemasu

Merged in PR #58 .

nemasu avatar Apr 13 '23 11:04 nemasu