bug-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug classpath/86737] New: HTTPURLConnection.getOutputStream() fails if


From: guillerodriguez.dev at gmail dot com
Subject: [Bug classpath/86737] New: HTTPURLConnection.getOutputStream() fails if called after connect()
Date: Mon, 30 Jul 2018 12:29:31 +0000

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86737

            Bug ID: 86737
           Summary: HTTPURLConnection.getOutputStream() fails if called
                    after connect()
           Product: classpath
           Version: 0.99
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: classpath
          Assignee: unassigned at gcc dot gnu.org
          Reporter: guillerodriguez.dev at gmail dot com
  Target Milestone: ---

As the summary says, calling HTTPURLConnection.getOutputStream() after
connect() fails with an exception, which is wrong according to the specs.

Here's the relevant code from HTTPURLConnection:

  public OutputStream getOutputStream()
    throws IOException
  {
    if (connected)
      {
        throw new ProtocolException("Already connected");
      }
  [...]

The docs for URLConnection
(https://docs.oracle.com/javase/7/docs/api/java/net/URLConnection.html) clearly
say the following:

===
In general, creating a connection to a URL is a multistep process:

[...]

1. The connection object is created by invoking the openConnection method on a
URL
2. The setup parameters and general request properties are manipulated.
3. The actual connection to the remote object is made, using the connect
method.
4. The remote object becomes available. The header fields and the contents of
the remote object can be accessed.

[...]

The following methods are used to access the header fields and the contents
after the connection is made to the remote object:

 * getContent
 * getHeaderField
 * getInputStream
 * getOutputStream <--
===


reply via email to

[Prev in Thread] Current Thread [Next in Thread]