本文整理汇总了Java中com.squareup.okhttp.Headers.names方法的典型用法代码示例。如果您正苦于以下问题:Java Headers.names方法的具体用法?Java Headers.names怎么用?Java Headers.names使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.squareup.okhttp.Headers
的用法示例。
在下文中一共展示了Headers.names方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: logHeaders
import com.squareup.okhttp.Headers; //导入方法依赖的package包/类
private void logHeaders(String prefix, Headers headers) {
for (String name : headers.names()) {
List<String> values = headers.values(name);
for (String value : values) {
logger.info(prefix + name + ": " + value);
}
}
}
示例2: logHeaders
import com.squareup.okhttp.Headers; //导入方法依赖的package包/类
private static void logHeaders(Headers headers) {
for (String headerName : headers.names()) {
for (String headerValue : headers.values(headerName)) {
Logger.d("Header - [" + headerName + ": " + headerValue + "]");
}
}
}
示例3: logRequest
import com.squareup.okhttp.Headers; //导入方法依赖的package包/类
public static void logRequest(final Request request) throws IOException
{
if (LOG.isLoggable(Level.FINE))
{
LOG.log(Level.FINE, String.format(">> %s %s", request.method(), request.url()));
Headers headers = request.headers();
for (String header : headers.names())
{
LOG.log(Level.FINE, String.format(">> %s: %s", header, headers.get(header)));
}
RequestBody body = request.body();
if (body != null)
{
ByteArrayOutputStream out = new ByteArrayOutputStream();
try
{
BufferedSink buffer = Okio.buffer(Okio.sink(out));
body.writeTo(buffer);
buffer.flush();
byte[] bytes = out.toByteArray();
if (bytes.length > 0)
{
LOG.log(Level.FINE,
String.format(">> Content-Type: %s", body.contentType()));
LOG.log(Level.FINE, String.format(">> Body: %s", new String(bytes)));
}
}
finally
{
out.close();
}
}
}
}
示例4: fromOkHttpHeaders
import com.squareup.okhttp.Headers; //导入方法依赖的package包/类
private static Map<String, List<String>> fromOkHttpHeaders(Headers headers) {
Map<String, List<String>> responseHeaders = new HashMap<String, List<String>>(headers.size());
for (String name : headers.names()) {
responseHeaders.put(name, headers.values(name));
}
return responseHeaders;
}