Hi all,
Well, the problem is that I'm trying to create a J2ME emulator, and for that, I'm using J2SE API to provide J2ME services in the way the J2ME API specifies. For that, I'm making a wrapper for HTTP, in a way that I use a J2SE HttpURLConnection to simulate the behavior of a J2ME HttpConnection. The problem is that they have different behavior regarding methods that cause the transition to the connected state, and also they behave differently on when to return exceptions.
For example, in J2ME, if I open a HTTP connection, and call connection.getDate(), this causes the connection to go to the connected state; therefore, if I call the method connection.setRequestProperty(), this method should throw an IOException, because the connection will be at the connected state. If I do the same on a instance of J2SE HttpURLConnection, no exception is thrown. Therefore I have to check if the connection is in the connected state in order to return the IOException.
Can anyone help me on this issue? Any hints?
Regards,
Fuad Abinader