01: /*
02: * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
03: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
04: */
05:
06: package com.sun.portal.providers.urlscraper;
07:
08: class Header {
09:
10: private String name = null;
11: private String value = null;
12:
13: public Header(String t) {
14: // The getHeaderField call on HttpURLConnection is returning
15: // "absolute uri" instead of "Location : absolute uri" as defined
16: // in HTTP spec. The following code works around that issue by
17: // checking for both kinds of values.
18: String loc = t.toLowerCase();
19: int nameIndex = loc.indexOf("location");
20: if (nameIndex != -1) {
21: int colonIndex = t.indexOf(":");
22: name = t.substring(0, colonIndex);
23: name = name.trim();
24: value = t.substring(colonIndex + 1);
25: value = value.trim();
26: } else {
27: name = "Location";
28: value = t;
29: }
30: }
31:
32: private Header() {
33: }
34:
35: public String toString() {
36: return name + ": " + value;
37: }
38:
39: public String getName() {
40: return name;
41: }
42:
43: public String getValue() {
44: return value;
45: }
46:
47: public void setName(String n) {
48: name = n;
49: }
50:
51: public void setValue(String v) {
52: value = v;
53: }
54: }
|