i've finally bumped up against this famed omission in the J2ME libraries, which as you might guess, quickly rears its ugly head when doing anything with the Atom API. the MIDP1 and MIDP2 libraries only support GET, POST, and HEAD with HTTP, which is totally idiotic, especially when you look at the reference implementation source:
from com.sun.midp.io.j2me.http.Protocol
/**
* Set the request method of the current connection.
*
* @param method request method is GET, HEAD or POST
* @exception IOException is thrown if the connection is already open
* @see #getRequestMethod
*/
public void setRequestMethod(String method) throws IOException {
if (state == CONNECT_STATE)
throw new IOException("connection already open");
if (!method.equals(HEAD) &&
!method.equals(GET) &&
!method.equals(POST)) {
throw new IOException("unsupported method: " + method);
}
this.method = method;
}
okay, great, so for no particular reason you just call it "unsupported" and then just set an instance variable which gets used
/*
* Note: the "ref" or fragment, is not sent to the server.
*/
if (http_proxy == null) {
reqLine = method + " " + filename
+ (url.query == null ? "" : "?" + url.query)
+ " " + HTTP_VERSION + "\r\n";
} else {
reqLine = method + " "
+ protocol + "://" + hostAndPort
+ filename
+ (url.query == null ? "" : "?" + url.query)
+ " " + HTTP_VERSION + "\r\n";
}
by just writing it out to the HTTP stream. i think if this allowed PUT it would just work....
well, okay, plenty of ways to work around this at lower levels or by delegation (subclassing would be great, but class bootstrapping isn't standard, especially in the JBlend VM that is used by the likes of crappy motorola phones and such...i'll see what i can do).
i also love how there is no Properties object defined in the MIDP APIs, but the first thing SUN does in there reference impl is create one...why not just include that too? jeesh.
Posted by Steve at September 26, 2004 11:46 PM | TrackBack