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

Fixes issue #4174 - Fix issues related to HttpHeaderManager.getDateHeader #4175

Merged
merged 2 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public long getDateHeader(String name) throws IllegalArgumentException {
DefaultHttpHeader header = headers.get(name.toUpperCase(locale));
try {
String value = header.getValue();
SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz");
SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", locale);
result = format.parse(value).getTime();
} catch (ParseException exception) {
throw new IllegalArgumentException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Enumeration;
import java.util.Locale;

import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -82,7 +84,7 @@ void testContainsHeader() {
@Test
void testGetDateHeader() {
DefaultHttpHeaderManager manager = new DefaultHttpHeaderManager();
SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz");
SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);
manager.addHeader("NAME", format.format(new Date()));
assertTrue(manager.getDateHeader("NAME") > 0);
}
Expand Down
Loading