From 8a5d1c92c4268791a2ba591ee13ec3dea4ffc2b4 Mon Sep 17 00:00:00 2001 From: mkoch Date: Tue, 30 Dec 2003 12:02:47 +0000 Subject: 2003-12-30 Michael Koch * gnu/java/net/protocol/http/Connection.java (requestProperties): New field. (addRequestProperty): New method. (getRequestProperty): New method. (setRequestProperty): New method. (getRequestProperties): New method. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@75228 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/gnu/java/net/protocol/http/Connection.java | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'libjava/gnu/java') diff --git a/libjava/gnu/java/net/protocol/http/Connection.java b/libjava/gnu/java/net/protocol/http/Connection.java index 5cced5cf0a2..1a6d45c1769 100644 --- a/libjava/gnu/java/net/protocol/http/Connection.java +++ b/libjava/gnu/java/net/protocol/http/Connection.java @@ -49,6 +49,7 @@ import java.net.ProtocolException; import java.net.Socket; import java.net.URL; import java.net.URLConnection; +import java.util.HashMap; import java.util.Iterator; import java.util.Map; import gnu.java.net.HeaderFieldHelper; @@ -104,6 +105,11 @@ public final class Connection extends HttpURLConnection */ private DataInputStream inputStream; + /** + * This object holds the request properties. + */ + private HashMap requestProperties = new HashMap(); + /** * This is the object that holds the header field information */ @@ -368,6 +374,41 @@ public final class Connection extends HttpURLConnection method); } + public void addRequestProperty(String key, String value) + { + if (connected) + throw new IllegalStateException("Already connected"); + + String old = (String) requestProperties.put(key, value); + + if (old != null) + requestProperties.put(key, old + "," + value); + } + + public String getRequestProperty(String key) + { + if (connected) + throw new IllegalStateException("Already connected"); + + return (String) requestProperties.get(key); + } + + public void setRequestProperty(String key, String value) + { + if (connected) + throw new IllegalStateException("Already connected"); + + requestProperties.put(key, value); + } + + public Map getRequestProperties() + { + if (connected) + throw new IllegalStateException("Already connected"); + + return requestProperties; + } + public String getHeaderField(String name) { if (!connected) -- cgit v1.2.3