本文整理匯總了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;
}