diff options
| author | Michael Koch <konqueror@gmx.de> | 2003-12-30 14:09:06 +0000 |
|---|---|---|
| committer | Michael Koch <konqueror@gmx.de> | 2003-12-30 14:09:06 +0000 |
| commit | 81d1592ca9f9ff5cd47ca4678618f47040bb6360 (patch) | |
| tree | 1e324df45565fde64437dee321ec0f416dce8d45 /gnu/java/net/protocol/http/Connection.java | |
| parent | 1c2af8f17032940823757ab54dac94044449d0fe (diff) | |
| download | classpath-81d1592ca9f9ff5cd47ca4678618f47040bb6360.tar.gz | |
2003-12-30 Michael Koch <konqueror@gmx.de>
* gnu/java/net/protocol/http/Connection.java
(outputStream): New field.
(bufferedOutputStream): New field.
(connect): Initialize outputStream and bufferedOutputStream.
(sendRequest): Create PrintWriter object from outputStream,
support HTTP 1.1, send missing HTTP headers and buffered output data
for POST method.
(getOutputStream): Set request method to POST if output stream is
used, return bufferedOutputStream.
(setRequestMethod): Allow HEAD and POST methods.
This fixes libgcj PR/6302 and libgcj PR/7752.
Diffstat (limited to 'gnu/java/net/protocol/http/Connection.java')
| -rw-r--r-- | gnu/java/net/protocol/http/Connection.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/gnu/java/net/protocol/http/Connection.java b/gnu/java/net/protocol/http/Connection.java index cea677230..d5b8f5205 100644 --- a/gnu/java/net/protocol/http/Connection.java +++ b/gnu/java/net/protocol/http/Connection.java @@ -52,6 +52,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; @@ -119,6 +120,11 @@ public final class Connection extends HttpURLConnection private ByteArrayOutputStream bufferedOutputStream; /** + * This object holds the request properties. + */ + private HashMap requestProperties = new HashMap(); + + /** * This is the object that holds the header field information */ private HeaderFieldHelper headers = new HeaderFieldHelper(); @@ -410,6 +416,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) |
