Class Info |
|---|
public static final class Headers.Builder Headers的构造器。 |
Qualifier and Type | Method Name and Description |
|---|---|
public Headers.Builder | add(String line) 添加消息头信息,格式:“name:value”。 |
public Headers.Builder | add(String name, String value) 添加消息头信息。 |
public Headers.Builder | addLenient(String line) 添加消息头信息,格式:“name:value”。 |
public Headers.Builder | addLenient(String name, String value) 添加消息头信息。 |
public Headers | build() 创建Headers实例。 |
public String | get(String name) 获取对应“name”的最后一个“value”值,不区分“name”大小写。 |
public Headers.Builder | removeAll(String name) 移除对应“name”的所有“value”值,不区分“name”大小写。 |
public Headers.Builder | set(String name, String value) 设置消息头信息,自动去除“value”首尾空格。 |
Method |
|---|
public Headers.Builder add(String line) 添加消息头信息,格式:“name:value”,会自动去除“name”和“value”的首尾空格,“name”取值范围为ASCII表中除空格外的所有可显示字符,“value”取值范围为ASCII表中换行符及所有可显示字符。当使用非指定范围内的字符时需与服务端约定使用UTF-8方式进行编码和解码。当传入不符合要求的字符串时,会抛出对应异常。 |
Parameters
Name | Description |
|---|---|
line | 待添加的消息头信息。 |
Returns
Type | Description |
|---|---|
Headers.Builder | Headers构造器。 |
Method |
|---|
public Headers.Builder add(String name, String value) 添加消息头信息,当使用非指定范围内的字符时,需与服务端约定使用UTF-8方式进行编码和解码。当传入不符合要求的字符串时,会抛出对应异常。 |
Parameters
Name | Description |
|---|---|
name | 消息头信息的“name”,取值范围:ASCII表中除空格外的所有可显示字符。 |
value | 消息头信息的“value”,自动去除首尾空格,取值范围:ASCII表中换行符及所有可显示字符。 |
Returns
Type | Description |
|---|---|
Headers.Builder | Headers构造器。 |
Method |
|---|
public Headers.Builder addLenient(String line) 添加消息头信息,格式:“name:value”。 |
Parameters
Name | Description |
|---|---|
line | 待添加的消息头信息。格式:“name:value”,转换时会自动去除“value”首尾空格。当传入字符串中不含“:”时,“name”值为"",“value”值为字符串的值;当字符串第一个字符为“:”时,“name”值为"",“value”值为“:”后的字符串。 |
Returns
Type | Description |
|---|---|
Headers.Builder | Headers构造器。 |
Method |
|---|
public Headers.Builder addLenient(String name, String value) 添加消息头信息。 |
Parameters
Name | Description |
|---|---|
name | 消息头信息的“name”。 |
value | 消息头信息的“value”,转换时会自动去除“value”首尾空格。 |
Returns
Type | Description |
|---|---|
Headers.Builder | Headers构造器。 |
Method |
|---|
public String get(String name) 获取对应“name”的最后一个“value”值,不区分“name”大小写。 |
Parameters
Name | Description |
|---|---|
name | 待获取消息头对应值的“name”值。 |
Returns
Type | Description |
|---|---|
String | 消息头对应“name”的最后一个“value”值,取值时会忽略“name”大小写,即“Name”和“name”取到的值一致。 |
Method |
|---|
public Headers.Builder removeAll(String name) 移除对应“name”的所有“value”值,不区分“name”大小写。 |
Parameters
Name | Description |
|---|---|
name | 待移除消息头信息的“name”值,移除时忽略“name”大小写。 |
Returns
Type | Description |
|---|---|
Headers.Builder | Headers构造器。 |
Method |
|---|
public Headers.Builder set(String name, String value) 设置消息头信息,自动去除“value”首尾空格。 |
Parameters
Name | Description |
|---|---|
name | 消息头信息的“name”值。 |
value | 消息头信息的“value”值。 |
Returns
Type | Description |
|---|---|
Headers.Builder | Headers构造器。 |
// Licensed to the Apache Software Foundation (ASF) under one or more // contributor license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright ownership. // The ASF licenses this file to You under the Apache License, Version 2.0 // (the "License"); you may not use this file except in compliance with // the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License.