Http type
MIDletPascal provides basic HTTP connectivity. Http connections are identified by their identifier variables which must be declared to be of 'http' type. The HTTP connection lifecycle is as follows:
The following example illustrates simple use of http connectivity:
var conn: http;
htmlBody: string;
contentType: string;
begin
if not openHttp(conn, 'http://www.google.com') then halt;
setHttpMethod(conn, GET);
addHttpHeader(conn, 'User-agent', 'MIDletPascal browser');
if sendHttpMessage(conn) <> 200 then halt;
htmlBody := getHttpResponse(conn);
contentType := getHttpHeader(conn, 'Content-type');
closeHttp(conn);
end.
The internal emulator does not support Http connections. Sun's Wireless Toolkit emulator is recommended for off-phone http testing!