?? httpsconnection.html
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc on Fri Sep 27 14:47:30 CDT 2002 --><TITLE>Mobile Information Device Profile 2.0: Interface HttpsConnection</TITLE><LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style"></HEAD><BODY BGCOLOR="white"><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_top"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/HttpsConnection.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><strong>MIDP 2.0</strong></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../javax/microedition/io/HttpConnection.html"><B>PREV CLASS</B></A> <B>NEXT CLASS</B></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../index.html" TARGET="_top"><B>FRAMES</B></A> <A HREF="HttpsConnection.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">javax.microedition.io</FONT><BR>Interface HttpsConnection</H2><DL><DT><B>All Superinterfaces:</B> <DD>Connection, ContentConnection, <A HREF="../../../javax/microedition/io/HttpConnection.html">HttpConnection</A>, InputConnection, OutputConnection, StreamConnection</DD></DL><HR><DL><DT>public interface <B>HttpsConnection</B><DT>extends <A HREF="../../../javax/microedition/io/HttpConnection.html">HttpConnection</A></DL><P>This interface defines the necessary methods and constants to establish a secure network connection. The URI format with scheme <CODE>https</CODE> when passed to <CODE>Connector.open</CODE> will return a <code>HttpsConnection</code>. <A HREF="http://www.ietf.org/rfc/rfc2818.txt">RFC 2818</A> defines the scheme. <p> A secure connection MUST be implemented by one or more of the following specifications: <UL> <LI>HTTP over TLS as documented in <A HREF="http://www.ietf.org/rfc/rfc2818.txt">RFC 2818</A> and TLS Protocol Version 1.0 as specified in <A HREF="http://www.ietf.org/rfc/rfc2246.txt">RFC 2246</A>. <LI>SSL V3 as specified in <A HREF="http://home.netscape.com/eng/ssl3/draft302.txt"> The SSL Protocol Version 3.0</A> </LI> <LI>WTLS as specified in <A HREF="http://www.wapforum.org/what/technical_1_2_1.htm"> WAP Forum Specifications June 2000 (WAP 1.2.1) conformance release</A> - Wireless Transport Layer Security document WAP-199. <LI>WAP(TM) TLS Profile and Tunneling Specification as specified in <A HREF="http://www.wapforum.com/what/technical.htm"> WAP-219-TLS-20010411-a</A> </UL> <p> HTTPS is the secure version of HTTP (IETF RFC2616), a request-response protocol in which the parameters of the request must be set before the request is sent. <p> In addition to the normal <code>IOExceptions</code> that may occur during invocation of the various methods that cause a transition to the Connected state, <code>CertificateException</code> (a subtype of <code>IOException</code>) may be thrown to indicate various failures related to establishing the secure link. The secure link is necessary in the <code>Connected</code> state so the headers can be sent securely. The secure link may be established as early as the invocation of <code>Connector.open()</code> and related methods for opening input and output streams and failure related to certificate exceptions may be reported. </p><br> <b>Example</b><br> <p>Open a HTTPS connection, set its parameters, then read the HTTP response.</p> <code>Connector.open</code> is used to open the URL and an <code>HttpsConnection</code> is returned. The HTTP headers are read and processed. If the length is available, it is used to read the data in bulk. From the <code>HttpsConnection</code> the <code>InputStream</code> is opened. It is used to read every character until end of file (-1). If an exception is thrown the connection and stream are closed. <code><PRE> void getViaHttpsConnection(String url) throws CertificateException, IOException { HttpsConnection c = null; InputStream is = null; try { c = (HttpsConnection)Connector.open(url); // Getting the InputStream ensures that the connection // is opened (if it was not already handled by // Connector.open()) and the SSL handshake is exchanged, // and the HTTP response headers are read. // These are stored until requested. is = c.openDataInputStream(); if c.getResponseCode() == HttpConnection.HTTP_OK) { // Get the length and process the data int len = (int)c.getLength(); if (len > 0) { byte[] data = new byte[len]; int actual = is.readFully(data); ... } else { int ch; while ((ch = is.read()) != -1) { ... } } } else { ... } } finally { if (is != null) is.close(); if (c != null) c.close(); } } </PRE> </code><P><DL><DT><B>Since: </B><DD>MIDP 2.0</DD><DT><B>See Also: </B><DD><A HREF="../../../javax/microedition/pki/CertificateException.html"><CODE>CertificateException</CODE></A></DL><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><A NAME="fields_inherited_from_class_javax.microedition.io.HttpConnection"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Fields inherited from interface javax.microedition.io.<A HREF="../../../javax/microedition/io/HttpConnection.html">HttpConnection</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../../javax/microedition/io/HttpConnection.html#GET">GET</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HEAD">HEAD</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_ACCEPTED">HTTP_ACCEPTED</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_BAD_GATEWAY">HTTP_BAD_GATEWAY</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_BAD_METHOD">HTTP_BAD_METHOD</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_BAD_REQUEST">HTTP_BAD_REQUEST</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_CLIENT_TIMEOUT">HTTP_CLIENT_TIMEOUT</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_CONFLICT">HTTP_CONFLICT</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_CREATED">HTTP_CREATED</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_ENTITY_TOO_LARGE">HTTP_ENTITY_TOO_LARGE</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_EXPECT_FAILED">HTTP_EXPECT_FAILED</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_FORBIDDEN">HTTP_FORBIDDEN</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_GATEWAY_TIMEOUT">HTTP_GATEWAY_TIMEOUT</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_GONE">HTTP_GONE</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_INTERNAL_ERROR">HTTP_INTERNAL_ERROR</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_LENGTH_REQUIRED">HTTP_LENGTH_REQUIRED</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_MOVED_PERM">HTTP_MOVED_PERM</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_MOVED_TEMP">HTTP_MOVED_TEMP</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_MULT_CHOICE">HTTP_MULT_CHOICE</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_NO_CONTENT">HTTP_NO_CONTENT</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_NOT_ACCEPTABLE">HTTP_NOT_ACCEPTABLE</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_NOT_AUTHORITATIVE">HTTP_NOT_AUTHORITATIVE</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_NOT_FOUND">HTTP_NOT_FOUND</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_NOT_IMPLEMENTED">HTTP_NOT_IMPLEMENTED</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_NOT_MODIFIED">HTTP_NOT_MODIFIED</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_OK">HTTP_OK</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_PARTIAL">HTTP_PARTIAL</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_PAYMENT_REQUIRED">HTTP_PAYMENT_REQUIRED</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_PRECON_FAILED">HTTP_PRECON_FAILED</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_PROXY_AUTH">HTTP_PROXY_AUTH</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_REQ_TOO_LONG">HTTP_REQ_TOO_LONG</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_RESET">HTTP_RESET</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_SEE_OTHER">HTTP_SEE_OTHER</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_TEMP_REDIRECT">HTTP_TEMP_REDIRECT</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_UNAUTHORIZED">HTTP_UNAUTHORIZED</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_UNAVAILABLE">HTTP_UNAVAILABLE</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_UNSUPPORTED_RANGE">HTTP_UNSUPPORTED_RANGE</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_UNSUPPORTED_TYPE">HTTP_UNSUPPORTED_TYPE</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_USE_PROXY">HTTP_USE_PROXY</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#HTTP_VERSION">HTTP_VERSION</A>, <A HREF="../../../javax/microedition/io/HttpConnection.html#POST">POST</A></CODE></TD>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -