public static class HTTPServer.Headers extends Object implements Iterable<HTTPServer.Header>
Headers class encapsulates a collection of HTTP headers.
Header names are treated case-insensitively, although this class retains their original case. Header insertion order is maintained as well.
| 限定符和类型 | 字段和说明 |
|---|---|
protected int |
count |
protected HTTPServer.Header[] |
headers |
| 构造器和说明 |
|---|
Headers() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
add(String name,
String value)
Adds a header with the given name and value to the end of this
collection of headers.
|
void |
addAll(HTTPServer.Headers headers)
Adds all given headers to the end of this collection of headers,
in their original order.
|
boolean |
contains(String name)
Returns whether there exists a header with the given name.
|
String |
get(String name)
Returns the value of the first header with the given name.
|
Date |
getDate(String name)
Returns the Date value of the header with the given name.
|
Map<String,String> |
getParams(String name)
Returns a header's parameters.
|
Iterator<HTTPServer.Header> |
iterator()
Returns an iterator over the headers, in their insertion order.
|
void |
remove(String name)
Removes all headers with the given name (if any exist).
|
HTTPServer.Header |
replace(String name,
String value)
Adds a header with the given name and value, replacing the first
existing header with the same name.
|
int |
size()
Returns the number of added headers.
|
void |
writeTo(OutputStream out)
Writes the headers to the given stream (including trailing CRLF).
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEach, spliteratorprotected HTTPServer.Header[] headers
protected int count
public int size()
public String get(String name)
name - the header name (case insensitive)public Date getDate(String name)
name - the header name (case insensitive)public boolean contains(String name)
name - the header name (case insensitive)public void add(String name, String value)
name - the header name (case insensitive)value - the header valuepublic void addAll(HTTPServer.Headers headers)
headers - the headers to addpublic HTTPServer.Header replace(String name, String value)
add(java.lang.String, java.lang.String).name - the header name (case insensitive)value - the header valuepublic void remove(String name)
name - the header name (case insensitive)public void writeTo(OutputStream out) throws IOException
out - the stream to write the headers toIOException - if an error occurspublic Map<String,String> getParams(String name)
name - the header name (case insensitive)public Iterator<HTTPServer.Header> iterator()
iterator 在接口中 Iterable<HTTPServer.Header>Copyright © 2021. All rights reserved.