-
Notifications
You must be signed in to change notification settings - Fork 0
대소문자를 구분하지 않는 Attributes #75
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
base: freddie-noel
Are you sure you want to change the base?
Changes from 12 commits
5106c52
532ad2e
c698959
76a3235
0d3fa81
b0ee9ae
0c06f60
780f6e9
2851f2a
dfe49f7
49d127e
66dcf7c
f61aa7f
8dbb272
41592da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,36 +16,54 @@ public static Attributes from(Map<String, String> attributes) { | |
| } | ||
|
|
||
| public static Attributes from(String headerText) { | ||
| Map<String, String> attributes = new LinkedHashMap<>(); | ||
| Attributes attributes = new Attributes(); | ||
|
|
||
| String[] splittedHeaderTexts = headerText.split(Const.CRLF); | ||
| for (String splittedHeaderText : splittedHeaderTexts) { | ||
| HttpRequestUtils.Pair pair = HttpRequestUtils.parseHeader(splittedHeaderText); | ||
|
|
||
| if (pair != null) { | ||
| attributes.put(pair.getKey(), pair.getValue()); | ||
| attributes.add(pair.getKey(), pair.getValue()); | ||
| } | ||
| } | ||
|
|
||
| return from(attributes); | ||
| return attributes; | ||
| } | ||
|
|
||
| public Attributes add(String key, String value) { | ||
| attributes.put(key, value); | ||
| public Attributes add(String targetKey, String value) { | ||
| for (String currentKey : attributes.keySet()) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍👍👍👍 |
||
| if (currentKey.equalsIgnoreCase(targetKey)) { | ||
| return this; | ||
| } | ||
| } | ||
|
|
||
| attributes.put(targetKey, value); | ||
| return this; | ||
| } | ||
|
|
||
| public Attributes addAll(Map<String, String> attributes) { | ||
| this.attributes.putAll(attributes); | ||
| for (String currentKey : attributes.keySet()) { | ||
| add(currentKey, attributes.get(currentKey)); | ||
| } | ||
|
|
||
| return this; | ||
| } | ||
|
|
||
| public String get(String key) { | ||
| return attributes.get(key); | ||
| public String get(String targetKey) { | ||
| for (String currentKey : attributes.keySet()) { | ||
| if (currentKey.equalsIgnoreCase(targetKey)) { | ||
| return attributes.get(currentKey); | ||
| } | ||
| } | ||
Dae-Hwa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| throw new IllegalArgumentException("일치하는 키가 없습니다."); | ||
|
||
| } | ||
|
|
||
| public String getOrDefault(String key, String defaultValue) { | ||
| return attributes.getOrDefault(key, defaultValue); | ||
| public String getOrDefault(String targetKey, String defaultValue) { | ||
| try { | ||
| return get(targetKey); | ||
| } catch (IllegalArgumentException e) { | ||
| return defaultValue; | ||
| } | ||
|
||
| } | ||
|
|
||
| public String toHeaderText() { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.