Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#921 show directory index (from PR #1033) #1094

Merged
merged 17 commits into from
Aug 22, 2016

Conversation

tejksat
Copy link
Contributor

@tejksat tejksat commented Aug 18, 2016

What do these changes do?

  • By default throws HTTP 403 - Forbidden if we access static directory
  • If static directory indexing is enabled - lists the static directory contents when we access it
  • If server is not permitted to access a static directory then it responses with HTTP 403 - Forbidden

Are there changes in behavior for the user?

UrlDispatcher.add_static got new flag - show_index, which will show index of a directory if explicitly set to True. By default, accessing directory index is forbidden (HTTP/403, show_index=False)

Related issue number

#921

Checklist

Points taken from PR #1033:

  • StaticRoute._directory_as_html():
    • Maybe it should be outside the class? Unit-testing would be easier that way..
      (This is not necessary as discussed with @asvetlov)
    • I would want a unit-test for this method to explicitly check that HTML is as we want (Check added)
    • Method looks cumbersome and has lots of newlines, so the output would be human readable (is this a priority?) (It is OK as discussed with @asvetlov)
    • There is currently missing coverage for L506 and L531 (Fixed)
    • Documentation should reflect the changes, though I have build problems ATM and cannot check docs as HTML (Added)

trimailov and others added 15 commits July 23, 2016 13:52
If we want to access a static file dir, it should return `Forbidden
(403)` by default.

Related: aio-libs#921
XXX: need for a response to return proper html

Related: aio-libs#921
Also I now return in place, instead of creating variable and returning
later, I am not a fan of returning somewehere inside a method, though if
we tried to return `ret` at the end as before, but I guess it's the most
clean pattern to do this.

This is because we have to conditional blocks, either of which can
return from the method. If first condtitonal creates `ret` variable,
later conditional may just raise `HTTPNotFound` which we do not want.
Though, I do not want to check that `ret` is populated either. Thus
return in place.

Related: aio-libs#921
- Better method name
- More human readable output (newlines)
- Title is shown as relative path to static directory and not as posix
  path
- Show directories with slash at the end of the name
And fix a minor typo
@codecov-io
Copy link

codecov-io commented Aug 18, 2016

Current coverage is 97.78% (diff: 100%)

No coverage report found for master at b75cb0a.

Powered by Codecov. Last update b75cb0a...c09128c

@asvetlov
Copy link
Member

Alexander Koshevoy added 2 commits August 18, 2016 19:19
@tejksat
Copy link
Contributor Author

tejksat commented Aug 19, 2016

@asvetlov done! Pls check.

@asvetlov asvetlov merged commit 90ec4eb into aio-libs:master Aug 22, 2016
@asvetlov
Copy link
Member

Thanks!

@lock
Copy link

lock bot commented Oct 29, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants