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

Add 308 Redirect #151

Closed
slavkoja opened this issue Dec 13, 2019 · 4 comments
Closed

Add 308 Redirect #151

slavkoja opened this issue Dec 13, 2019 · 4 comments

Comments

@slavkoja
Copy link

slavkoja commented Dec 13, 2019

Please add 308 code to redirect codes.

The 308 code is defined as permanent redirect, which preservers POST method, see RFC 7538.

thanks

@temoto
Copy link
Member

temoto commented Dec 17, 2019

Hey I saw this, but was busy this week, will add today. Thanks for keeping up with HTTP completeness.

temoto added a commit that referenced this issue Dec 19, 2019
…irect

- invalidate cache after request per RFC2616 Section 13.10
  before: `method not in ["GET", "HEAD"]`
  now: `method in h.invalidate_methods`, default: DELETE,POST,PUT
- 308 may be cached not by default as per RFC7538, but only with
  relevant headers
- Http new attributes: safe_methods, invalidate_methods are public API,
  type is anything with `contains` operator, tuple is recommended.
  Defaults are in upper case module level constants.
  As of 2019-12-19, SAFE_METHODS only include GET,HEAD to minimise
  problems from changing much behavior at once.
  Please, expect default SAFE_METHODS to become GET,HEAD,OPTIONS,TRACE as per RFC7231.

#151
temoto added a commit that referenced this issue Dec 19, 2019
…irect

- support 308 permanent redirect with same method
- Http() new attribute, `safe_methods` is public API,
  type is anything with `contains` operator, tuple is recommended.
  Defaults are GET,HEAD,OPTIONS,TRACE as per RFC7231.
- invalidate cache after request per RFC2616 Section 13.10
  before: `method not in ["GET", "HEAD"]`
  now: `method not in ["GET", "HEAD", "OPTIONS", "TRACE"]` and adjustable
- 308 may be cached not by default as per RFC7538, but only with
  relevant headers

#151
temoto added a commit that referenced this issue Dec 19, 2019
…irect

- support 308 permanent redirect with same method
- Http() new attribute, `safe_methods` is public API,
  type is anything with `contains` operator, tuple is recommended.
  Defaults are GET,HEAD,OPTIONS,TRACE as per RFC7231.
- invalidate cache after request per RFC2616 Section 13.10
  before: `method not in ["GET", "HEAD"]`
  now: `method not in ["GET", "HEAD", "OPTIONS", "TRACE"]` and adjustable
- 308 may be cached not by default as per RFC7538, but only with
  relevant headers

#151
temoto added a commit that referenced this issue Dec 19, 2019
…irect

- support 308 permanent redirect with same method
- Http() new attribute, `safe_methods` is public API,
  type is anything with `contains` operator, tuple is recommended.
  Defaults are GET,HEAD,OPTIONS,TRACE as per RFC7231.
- invalidate cache per https://tools.ietf.org/html/rfc7234#section-4.4
  before: `method not in [GET, HEAD]`
  now: `method not in [GET, HEAD, OPTIONS, TRACE]` and adjustable
- 308 may be cached not by default as per RFC7538, but only with
  relevant headers

#151
@temoto
Copy link
Member

temoto commented Dec 19, 2019

@slavkoja please, try this

pip install https://github.com/httplib2/httplib2/archive/45441b2f0ea6180853b087f77169f44ce726a508.zip

@slavkoja
Copy link
Author

Seems to work, while i didn't install it via pip.

Simple debug output, only hostname changed, the URL is redirected from HTTP to HTTPS via 308 code:

httplib2 path: /home/XY/tmp/httplib2-45441b2f0ea6180853b087f77169f44ce726a508/python3/httplib2/__init__.py

connect: (example.org, 80) ************
send: b'GET / HTTP/1.1\r\nHost: example.org\r\nuser-agent: Python-httplib2/0.15.0 (gzip)\r\naccept-encoding: gzip, deflate\r\n\r\n'
reply: 'HTTP/1.1 308 Permanent Redirect\r\n'
header: Server: nginx
header: Date: Fri, 20 Dec 2019 17:48:26 GMT
header: Content-Type: text/html
header: Content-Length: 164
header: Connection: keep-alive
header: Keep-Alive: timeout=10
header: Location: https://example.org/
header: Expires: Fri, 20 Dec 2019 17:48:25 GMT
header: Cache-Control: no-cache
header: X-Frame-Options: SAMEORIGIN
connect: (example.org, 443)
send: b'GET / HTTP/1.1\r\nHost: example.org\r\nuser-agent: Python-httplib2/0.15.0 (gzip)\r\naccept-encoding: gzip, deflate\r\n\r\n'
reply: 'HTTP/1.1 200 OK\r\n'
header: Server: nginx
header: Date: Fri, 20 Dec 2019 17:48:26 GMT
header: Content-Type: text/html; charset=UTF-8
header: Transfer-Encoding: chunked
header: Connection: keep-alive
header: Keep-Alive: timeout=10
header: Vary: Accept-Encoding
header: Expires: Fri, 20 Dec 2019 17:53:26 GMT
header: Cache-Control: max-age=300
header: X-Frame-Options: SAMEORIGIN
header: Content-Encoding: gzip

thanks

@temoto
Copy link
Member

temoto commented Dec 20, 2019

Merged in master. Have a great time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants