Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

[Bug 1385315] Use 302 not 301 for locale based redirect #4345

Merged
merged 2 commits into from
Aug 9, 2017

Conversation

safwanrahman
Copy link
Contributor

We should redirect the visitor with 302 redirect rather than 301
@jwhitlock r?

@jwhitlock
Copy link
Contributor

Please fix the flake8 error.

@codecov-io
Copy link

codecov-io commented Aug 6, 2017

Codecov Report

Merging #4345 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #4345   +/-   ##
=======================================
  Coverage   88.33%   88.33%           
=======================================
  Files         163      163           
  Lines       10233    10233           
  Branches     1420     1420           
=======================================
  Hits         9039     9039           
  Misses        968      968           
  Partials      226      226
Impacted Files Coverage Δ
kuma/core/middleware.py 83.75% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bc3f933...a6cda78. Read the comment docs.

@jwhitlock jwhitlock self-requested a review August 7, 2017 15:03
@jwhitlock jwhitlock self-assigned this Aug 7, 2017
Copy link
Contributor

@jwhitlock jwhitlock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @safwanrahman, this is what I asked for in PR #4321.

Can you combine the import statement for django.http? You'll have to use parenthesis like in kuma/core/tests/test_decorators.py

@@ -4,6 +4,7 @@
from django.conf import settings
from django.core import urlresolvers
from django.http import HttpResponseForbidden, HttpResponsePermanentRedirect
from django.http import HttpResponseRedirect
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be combined with the above import statement

return HttpResponsePermanentRedirect(urlparams(new_path, **query))

# Never use HttpResponsePermanentRedirect here.
# Its a temporary redirect and should return with http 302, not 301
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure in this case. I could argue that:

https://developer.mozilla.org/en-US/docs/Mozilla?lang=de

should be a permanent redirect to:

https://developer.mozilla.org/de/docs/Mozilla

As far as I can tell from the code and the analytics, the ?lang=foo feature is never used. This path and the one test that exercises it should probably be dropped. But that's a new PR.

So 👍 for now, for consistency.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update: it looks like ?lang=de is used in the footer language selector when JS is disabled. And, because JS is disabled, it doesn't show up in Google Analytics 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://developer.mozilla.org/en-US/docs/Mozilla?lang=de

should be a permanent redirect to:

https://developer.mozilla.org/de/docs/Mozilla

Like, If I go to bn-BD locale for some reason, I dont want to be there permanently.

@safwanrahman
Copy link
Contributor Author

@jwhitlock fixed the nit. r?

@jwhitlock
Copy link
Contributor

OK for now. Someday I'll turn on 80-column lines in flake8....

@jwhitlock jwhitlock merged commit 6cbc66c into mdn:master Aug 9, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants