Package com.authlete.http
Class ForwardedFieldValue
java.lang.Object
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<ForwardedElement>,Collection<ForwardedElement>,List<ForwardedElement>,RandomAccess,SequencedCollection<ForwardedElement>
This class represents the value of the
Forwarded HTTP field as defined
in RFC 7239:
Forwarded HTTP Extension, Section 4. Forwarded HTTP Header Field.
Definition
Forwarded = 1#forwarded-element
forwarded-element =
[ forwarded-pair ] *( ";" [ forwarded-pair ] )
forwarded-pair = token "=" value
value = token / quoted-string
token = <Defined in [RFC7230], Section 3.2.6>
quoted-string = <Defined in [RFC7230], Section 3.2.6>
Sample Code
ForwardedFieldValue ffv = ForwardedFieldValue.parse(String.join(", ", "for=\"_gazonk\"", "For=\"[2001:db8:cafe::17]:4711\"", "for=192.0.2.60;proto=http;by=203.0.113.43", "for=192.0.2.43;host=example.com" )); assertNotNull(ffv); assertEquals(4, ffv.size()); // 0 assertEquals("_gazonk", ffv.get(0).getFor()); // 1 assertEquals("[2001:db8:cafe::17]:4711", ffv.get(1).getFor()); // 2 assertEquals("192.0.2.60", ffv.get(2).getFor()); assertEquals("http", ffv.get(2).getProto()); assertEquals("203.0.113.43", ffv.get(2).getBy()); // 3 assertEquals("192.0.2.43", ffv.get(3).getFor()); assertEquals("example.com", ffv.get(3).getHost());
- See Also:
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount -
Constructor Summary
ConstructorsConstructorDescriptionThe default constructor.ForwardedFieldValue(int capacity) A constructor with the initial capacity.ForwardedFieldValue(Collection<? extends ForwardedElement> elements) A constructor with the initial elements. -
Method Summary
Modifier and TypeMethodDescriptionstatic ForwardedFieldValueParse the input string as the value of aForwardedHTTP field.toString()Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, addFirst, addLast, clear, clone, contains, ensureCapacity, equals, forEach, get, getFirst, getLast, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeFirst, removeIf, removeLast, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSizeMethods inherited from class java.util.AbstractCollection
containsAllMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, stream, toArrayMethods inherited from interface java.util.List
containsAll, reversed
-
Constructor Details
-
ForwardedFieldValue
public ForwardedFieldValue()The default constructor. -
ForwardedFieldValue
A constructor with the initial elements.- Parameters:
elements- The initial elements.
-
ForwardedFieldValue
public ForwardedFieldValue(int capacity) A constructor with the initial capacity.- Parameters:
capacity- The initial capacity.
-
-
Method Details
-
toString
- Overrides:
toStringin classAbstractCollection<ForwardedElement>
-
parse
Parse the input string as the value of aForwardedHTTP field.- Parameters:
input- A string to be parsed as the value of aForwardedHTTP field.- Returns:
- The parsed value of the
ForwardedHTTP field. - Throws:
ParseCancellationException- The input string could not be parsed successfully.
-