1 27 package de.nava.informa.utils; 28 29 import java.net.HttpURLConnection ; 30 31 35 public class HttpHeaderUtils { 36 37 42 static public void setIfModifiedSince(HttpURLConnection conn, long value) { 43 if ( value > 0 ) 44 conn.setIfModifiedSince( value ); 45 } 46 47 53 static public void setETagValue(HttpURLConnection conn, String etag) { 54 if (etag !=null) { 55 conn.setRequestProperty("If-None-Match", etag); 56 } 57 } 58 59 static public long getLastModified(HttpURLConnection conn) { 60 long result = conn.getHeaderFieldDate("Last-Modified", 0L); 61 return result; 62 } 63 64 static public String getETagValue(HttpURLConnection conn) { 65 return conn.getHeaderField("ETag"); 66 } 67 68 static public void setUserAgent(HttpURLConnection conn, String agent) { 69 if ( agent == null ) 70 return; 71 conn.setRequestProperty("User-Agent",agent); 72 } 73 } 74 | Popular Tags |