Here you can find the source of copyHttpHeaders(@Nonnull final HttpURLConnection aConn, @Nonnull final InternetHeaders aHeaders)
Parameter | Description |
---|---|
aConn | Connection |
aHeaders | Headers |
public static void copyHttpHeaders(@Nonnull final HttpURLConnection aConn, @Nonnull final InternetHeaders aHeaders)
//package com.java2s; import java.net.HttpURLConnection; import java.util.List; import java.util.Map; import javax.annotation.Nonnull; import javax.mail.internet.InternetHeaders; public class Main { /**/*from w w w .j av a2 s . c o m*/ * Copy headers from an Http connection to an InternetHeaders object * * @param aConn * Connection * @param aHeaders * Headers */ public static void copyHttpHeaders(@Nonnull final HttpURLConnection aConn, @Nonnull final InternetHeaders aHeaders) { for (final Map.Entry<String, List<String>> aConnHeader : aConn.getHeaderFields().entrySet()) { final String sHeaderName = aConnHeader.getKey(); if (sHeaderName != null) for (final String sHeaderValue : aConnHeader.getValue()) { if (aHeaders.getHeader(sHeaderName) == null) aHeaders.setHeader(sHeaderName, sHeaderValue); else aHeaders.addHeader(sHeaderName, sHeaderValue); } } } }