1 package net.matuschek.http; 2 3 6 7 14 public class HttpHeader { 15 16 17 public final static String CACHE_CONTROL = "Cache-Control"; 18 public final static String CONTENT_LENGTH = "Content-Length"; 19 public final static String CONTENT_TYPE = "Content-Type"; 20 public final static String DATE = "Date"; 21 public final static String LAST_MODIFIED = "Last-Modified"; 22 public final static String LOCATION = "location"; 23 public final static String SERVER = "Server"; 24 public final static String SET_COOKIE = "Set-Cookie"; 25 public final static String TRANSFER_ENCODING = "Transfer-Encoding"; 26 27 28 public final static String CONTENT_MD5 = "Content-MD5"; 29 30 31 private String name=""; 32 33 34 private String value=""; 35 36 39 public HttpHeader(String name, String value) { 40 this.name=name; 41 this.value=value; 42 } 43 44 48 public HttpHeader(String httpLine) { 49 int pos=0; 50 pos=httpLine.indexOf(":"); 51 if (pos == -1) { return; } 52 53 name=httpLine.substring(0,pos); 54 value=httpLine.substring(pos+1).trim(); 55 } 56 57 public String getName() { 58 return name; 59 } 60 61 public void setName(String name) { 62 this.name = name; 63 } 64 65 public String getValue() { 66 return value; 67 } 68 69 public void setValue(String value) { 70 this.value = value; 71 } 72 73 public String toString() { 74 return toLine(); 75 } 76 77 81 public String toLine() { 82 return name+": "+value; 83 } 84 85 89 public boolean isSetCookie() { 90 return name.equalsIgnoreCase(SET_COOKIE); 91 } 92 93 } 94 | Popular Tags |