-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[UNDERTOW-2194] - improve cookie parsing
- Loading branch information
Showing
8 changed files
with
509 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
core/src/main/java/io/undertow/server/MapDelegatingToMultiValueStorage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package io.undertow.server; | ||
|
||
import java.util.Collection; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
@Deprecated | ||
class MapDelegatingToMultiValueStorage<K, V> implements Map<K, V> { | ||
|
||
private final MultiValueHashListStorage<K, V> target; | ||
|
||
MapDelegatingToMultiValueStorage(MultiValueHashListStorage<K, V> target) { | ||
super(); | ||
this.target = target; | ||
} | ||
|
||
@Override | ||
public int size() { | ||
// this wont be accurate | ||
return target.size(); | ||
} | ||
|
||
@Override | ||
public boolean isEmpty() { | ||
return target.isEmpty(); | ||
} | ||
|
||
@Override | ||
public boolean containsKey(Object key) { | ||
return target.containsKey(key); | ||
} | ||
|
||
@Override | ||
public boolean containsValue(Object value) { | ||
return target.containsValue(value); | ||
} | ||
|
||
@Override | ||
public V get(Object key) { | ||
// this will roughly mimic it | ||
Collection<V> lst = target.get((K) key); | ||
if (lst != null && lst.size() > 0) { | ||
return lst.iterator().next(); | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
@Override | ||
public V put(K key, V value) { | ||
Collection<V> rems = target.removeAll(key); | ||
target.put(key, value); | ||
if (rems != null && rems.size() > 0) { | ||
return rems.iterator().next(); | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
@Override | ||
public V remove(Object key) { | ||
Collection<V> rems = target.removeAll(key); | ||
if (rems != null && rems.size() > 0) { | ||
return rems.iterator().next(); | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
@Override | ||
public void putAll(Map<? extends K, ? extends V> m) { | ||
for(Entry<? extends K, ? extends V> vk:m.entrySet()) { | ||
target.removeAll(vk.getKey()); | ||
} | ||
for(Entry<? extends K, ? extends V> vk:m.entrySet()) { | ||
target.put(vk.getKey(),vk.getValue()); | ||
} | ||
} | ||
|
||
@Override | ||
public void clear() { | ||
target.clear(); | ||
} | ||
|
||
@Override | ||
public Set<K> keySet() { | ||
return target.keySet(); | ||
} | ||
|
||
@Override | ||
public Collection<V> values() { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public Set<Entry<K, V>> entrySet() { | ||
throw new RuntimeException(); | ||
} | ||
|
||
} |
Oops, something went wrong.