Skip to content

Commit

Permalink
Merge pull request #399 from arXiv/fix-expires-header
Browse files Browse the repository at this point in the history
Fix expires header
  • Loading branch information
bdc34 authored Oct 9, 2023
2 parents 9f6ab59 + 1ea91ea commit d40bf9a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion browse/controllers/archive_page/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def category_list(archive_id: str) -> List[Dict[str, str]]:

def _write_expires_header(response_headers: Dict[str, Any]) -> None:
"""Writes an expires header for the response."""
response_headers["Expires"] = abs_expires_header(biz_tz())[1]
response_headers["Expires"] = abs_expires_header(biz_tz())


DAYS = ["{:0>2d}".format(i) for i in range(1, 32)]
Expand Down
6 changes: 3 additions & 3 deletions browse/controllers/response_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ def guess_next_update_utc(arxiv_business_tz: ZoneInfo, dt: Optional[datetime] =
return (possible_publish_dt.astimezone(tz=timezone.utc), likely_in_publish)


def abs_expires_header(arxiv_business_tz: ZoneInfo) -> Tuple[str, str]:
def abs_expires_header(arxiv_business_tz: ZoneInfo) -> str:
"""Get the expires header key and value that should be used by abs."""
(next_update_dt, likely_in_publish) = guess_next_update_utc(arxiv_business_tz)
if likely_in_publish:
return ('Expires', '-1')
return '-1'
else:
return ('Expires', mime_header_date(next_update_dt))
return mime_header_date(next_update_dt)


def mime_header_date(dt: datetime) -> str:
Expand Down
8 changes: 4 additions & 4 deletions tests/test_browse.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,10 +375,10 @@ def test_long_author_colab(self):

self.assertIsNotNone(
colab['href'], '<a> tag in title should have href')
self.assertEqual(
colab['href'], 'https://arxiv.org/search/physics?searchtype=author&query=ILL%2FESS%2FLiU+collaboration')
self.assertEqual(
colab.text, 'ILL/ESS/LiU collaboration for the development of the B10 detector technology in the framework of the CRISP project')
self.assertRegex(colab['href'],
'search\/physics\?searchtype=author\&query=ILL.ESS.LiU\+collaboration')
self.assertEqual(colab.text,
'ILL/ESS/LiU collaboration for the development of the B10 detector technology in the framework of the CRISP project')

@unittest.skip("In current implementation, conflicts with comma test below.")
def test_space_in_author_list(self):
Expand Down

0 comments on commit d40bf9a

Please sign in to comment.