diff options
| author | Michael Koch <konqueror@gmx.de> | 2003-12-28 21:50:38 +0000 |
|---|---|---|
| committer | Michael Koch <konqueror@gmx.de> | 2003-12-28 21:50:38 +0000 |
| commit | 005a31fd6103eb0014755d5d9adbfc839d51a408 (patch) | |
| tree | db1bf6b135459e79eee50ed88f2da3b70f28c330 /gnu/java/net/protocol/http/Connection.java | |
| parent | 94464b5f7d501e94b4d6a4cf557242b3c5b401e2 (diff) | |
| download | classpath-005a31fd6103eb0014755d5d9adbfc839d51a408.tar.gz | |
2003-12-28 Michael Koch <konqueror@gmx.de>
* gnu/java/net/HeaderFieldHelper.java
(getHeaderFieldValueByKey): New method.
(getHeaderFields): New method.
* gnu/java/net/protocol/http/Connection.java
(connect): Lowercase key before adding to HeaderFieldHelper object.
(getHeaderField): New method.
(getHeaderFields): New method.
Diffstat (limited to 'gnu/java/net/protocol/http/Connection.java')
| -rw-r--r-- | gnu/java/net/protocol/http/Connection.java | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/gnu/java/net/protocol/http/Connection.java b/gnu/java/net/protocol/http/Connection.java index 6cf7cd42c..cea677230 100644 --- a/gnu/java/net/protocol/http/Connection.java +++ b/gnu/java/net/protocol/http/Connection.java @@ -161,7 +161,6 @@ public final class Connection extends HttpURLConnection inputStream = new DataInputStream(new BufferedInputStream(socket.getInputStream())); - outputStream = new BufferedOutputStream (socket.getOutputStream()); bufferedOutputStream = new ByteArrayOutputStream (256); //default is too small @@ -250,7 +249,7 @@ public final class Connection extends HttpURLConnection String line = inputStream.readLine(); String saveline = line; int idx = line.indexOf (" "); - + if ((idx == -1) || (line.length() < (idx + 6))) throw new IOException ("Server reply was unparseable: " + saveline); @@ -303,7 +302,7 @@ public final class Connection extends HttpURLConnection { if (key != null) { - headers.addHeaderField (key, value); + headers.addHeaderField (key.toLowerCase(), value); key = null; value = null; } @@ -333,7 +332,7 @@ public final class Connection extends HttpURLConnection if (key != null) { - headers.addHeaderField (key, value); + headers.addHeaderField (key.toLowerCase(), value.toLowerCase()); } } @@ -411,6 +410,36 @@ public final class Connection extends HttpURLConnection method); } + public String getHeaderField(String name) + { + if (!connected) + try + { + connect(); + } + catch (IOException x) + { + return null; + } + + return (String) headers.getHeaderFieldValueByKey(name.toLowerCase()); + } + + public Map getHeaderFields() + { + if (!connected) + try + { + connect(); + } + catch (IOException x) + { + return null; + } + + return headers.getHeaderFields(); + } + /** * This method returns the header field value at the specified numeric * index. |
