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

/source redirects to /source.pdf for PDF source files #1407

Merged
merged 1 commit into from
Jul 26, 2023
Merged

Conversation

longhotsummer
Copy link
Contributor

@longhotsummer longhotsummer commented Jul 26, 2023

This ensures that documents that are pure PDF are only served from a single URL (/source.pdf) which is good for caching, google and pocketlaw.

Also harmonises download headers for /source and /source.pdf

Non-PDF:

$ http -p Hh http://localhost:8000/akn/ug/judgment/ughc/2009/165/eng@2009-09-29/source
GET /akn/ug/judgment/ughc/2009/165/eng@2009-09-29/source HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: localhost:8000
User-Agent: HTTPie/3.2.1

HTTP/1.1 200 OK
Cache-Control: max-age=86400
Content-Disposition: inline; filename=In Re Resty Nanyanzi and Joyce Kisakye (Infants) (Family Cause No 122 of 2009) 2009 UGHC 165 (29 September 2009).rtf
Content-Language: en
Content-Length: 53663
Content-Type: application/rtf
...

---

$ http -p Hh http://localhost:8000/akn/ug/judgment/ughc/2009/165/eng@2009-09-29/source.pdf
GET /akn/ug/judgment/ughc/2009/165/eng@2009-09-29/source.pdf HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: localhost:8000
User-Agent: HTTPie/3.2.1

HTTP/1.1 200 OK
Cache-Control: max-age=86400
Content-Disposition: inline; filename=In Re Resty Nanyanzi and Joyce Kisakye (Infants) (Family Cause No 122 of 2009) 2009 UGHC 165 (29 September 2009).pdf
Content-Language: en
Content-Length: 71890
Content-Type: application/pdf
...

PDF:

$ http -p Hh http://localhost:8000/akn/za/judgment/foo/2023/1/eng@2023-01-01/source
GET /akn/za/judgment/foo/2023/1/eng@2023-01-01/source HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: localhost:8000
User-Agent: HTTPie/3.2.1

HTTP/1.1 302 Found
Content-Language: en
Content-Length: 0
Content-Type: text/html; charset=utf-8
Date: Wed, 26 Jul 2023 09:21:41 GMT
Location: /akn/za/judgment/foo/2023/1/eng@2023-01-01/source.pdf
...

---

$ http -p Hh http://localhost:8000/akn/za/judgment/foo/2023/1/eng@2023-01-01/source.pdf
GET /akn/za/judgment/foo/2023/1/eng@2023-01-01/source.pdf HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: localhost:8000
User-Agent: HTTPie/3.2.1

HTTP/1.1 200 OK
Cache-Control: max-age=86400
Content-Disposition: inline; filename=test for pdf 2023 FOO 1 (1 January 2023).pdf
Content-Language: en
Content-Length: 255768
Content-Type: application/pdf
...

This ensures that documents that are pure PDF are only
served from a single URL (/source.pdf) which is good for caching,
google and pocketlaw.
@longhotsummer longhotsummer merged commit 4b4bb0d into main Jul 26, 2023
9 checks passed
@longhotsummer longhotsummer deleted the pdf branch July 26, 2023 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants