亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? httpsposter.java

?? J2ME MIDP_Example_Applications
?? JAVA
字號:
// Copyright 2003 Nokia Corporation.
//
// THIS SOURCE CODE IS PROVIDED 'AS IS', WITH NO WARRANTIES WHATSOEVER,
// EXPRESS OR IMPLIED, INCLUDING ANY WARRANTY OF MERCHANTABILITY, FITNESS
// FOR ANY PARTICULAR PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE
// OR TRADE PRACTICE, RELATING TO THE SOURCE CODE OR ANY WARRANTY OTHERWISE
// ARISING OUT OF ANY PROPOSAL, SPECIFICATION, OR SAMPLE AND WITH NO
// OBLIGATION OF NOKIA TO PROVIDE THE LICENSEE WITH ANY MAINTENANCE OR
// SUPPORT. FURTHERMORE, NOKIA MAKES NO WARRANTY THAT EXERCISE OF THE
// RIGHTS GRANTED HEREUNDER DOES NOT INFRINGE OR MAY NOT CAUSE INFRINGEMENT
// OF ANY PATENT OR OTHER INTELLECTUAL PROPERTY RIGHTS OWNED OR CONTROLLED
// BY THIRD PARTIES
//
// Furthermore, information provided in this source code is preliminary,
// and may be changed substantially prior to final release. Nokia Corporation
// retains the right to make changes to this source code at
// any time, without notice. This source code is provided for informational
// purposes only.
//
// Nokia and Nokia Connecting People are registered trademarks of Nokia
// Corporation.
// Java and all Java-based marks are trademarks or registered trademarks of
// Sun Microsystems, Inc.
// Other product and company names mentioned herein may be trademarks or
// trade names of their respective owners.
//
// A non-exclusive, non-transferable, worldwide, limited license is hereby
// granted to the Licensee to download, print, reproduce and modify the
// source code. The licensee has the right to market, sell, distribute and
// make available the source code in original or modified form only when
// incorporated into the programs developed by the Licensee. No other
// license, express or implied, by estoppel or otherwise, to any other
// intellectual property rights is granted herein.
package whiteboard;

import java.io.*;
import java.util.*;
import javax.microedition.io.*;
import javax.microedition.lcdui.*;
import javax.microedition.pki.*;

/**
 *  This class accepts and queues POST and GET requests for a particular URL,
 *  and services them in first-in-first-out order. Using the queue allows it to
 *  be thread-safe without forcing its clients ever to block. It also accept
 *  alternative MIME-types: It Supports Basic Authentication
 */
class HttpsPoster
    implements Runnable
{
    protected String url;
    protected Display display;
    protected volatile boolean aborting = false;
    protected Vector requestQueue = new Vector();
    // store the last valid credentials
    protected String credentials = null;
    protected String username = null, password = null;

    HttpsPoster(Display display, String url)
    {
        this.display = display;
        this.url = url;
        Thread thread = new Thread(this);
        thread.start();
    }


    void sendRequest(String type,
                     String request,
                     HttpPosterListener listener)
        throws IOException
    {
        sendRequest(type, null, request, listener);
    }


    synchronized void sendRequest(String type,
                                  String mimeType,
                                  String request,
                                  HttpPosterListener listener)
        throws IOException
    {
        // Create a new request and add it to the queue
        HttpRequest newRequest = new HttpRequest();
        newRequest.type = type;
        newRequest.request = request;
        newRequest.listener = listener;
        newRequest.mimeType = mimeType;
        requestQueue.addElement(newRequest);
        // wake up sending thread
        notify();
    }


    public void run()
    {
        running :
        while (!aborting)
        {
            HttpRequest request = null;

            synchronized (this)
            {
                while (requestQueue.size() == 0)
                {
                    try
                    {
                        // releases lock
                        wait();
                    }
                    catch (InterruptedException e)
                    {
                        // Ignore this thread is not interrupted in MIDP
                    }

                    if (aborting)
                    {
                        break running;
                    }
                }

                request = (HttpRequest) (requestQueue.elementAt(0));
                requestQueue.removeElementAt(0);
            }

            // sendRequest must have notified us
            doSend(request.type,
                   request.mimeType,
                   request.request,
                   request.listener);
        }
    }



    private void doSend(String type, String mimeType,
                        String requestStr, HttpPosterListener listener)
    {
        HttpsConnection conn = null;
        InputStream in = null;
        String responseStr = null;
        String errorStr = "";
        boolean wasError = false;
        CertificateException exc = null;
        try
        {
            int responseCode;
            do
            {
                conn = (HttpsConnection) Connector.open(url);

                // Set the request method and headers
                conn.setRequestMethod(type);

                // write request
                writeRequest(conn, requestStr, mimeType);

                // read response
                responseStr = readResponse(conn);

                responseCode = conn.getResponseCode();
                switch (responseCode)
                {
                    case HttpConnection.HTTP_OK:
                        break;
                    case HttpConnection.HTTP_UNAUTHORIZED:
                        // missing credentials when server requires
                        // them, or credentials sent but invalid
                        credentials = getCredentials(
                            conn.getHeaderField("WWW-Authenticate"));
                        conn.close();
                        // open again, this time with credentials
                        break;
                    default:
                        throw new IOException(
                          "Unsupported response code: "
                          + responseCode);
                }
            } while (responseCode != HttpConnection.HTTP_OK);

            // support URL rewriting for session handling
            String rewrittenUrl = conn.getHeaderField("X-RewrittenURL");
            if (rewrittenUrl != null)
            {
                // use this new one in future
                url = rewrittenUrl;
            }
        }
        catch (CertificateException e)
        {
            wasError = true;
            errorStr = e.getMessage();
            exc = e;
        }
        catch (IOException e)
        {
            wasError = true;
            errorStr = e.getMessage();
        }
        catch (SecurityException e)
        {
            // user permission was denied
            wasError = true;
            errorStr = e.getMessage();
        }
        finally
        {
            if (conn != null)
            {
                try
                {
                    conn.close();
                }
                catch (IOException e)
                {
                    // already closing, just ignore
                }
            }
        }

        if (wasError)
        {
            if (exc != null)
            {
                listener.handleCertificateError(exc);
            }
            else
            {
                listener.handleHttpError(errorStr);
            }
        }
        else
        {
            listener.receiveHttpResponse(responseStr);
        }
    }


    private void writeRequest(HttpConnection conn,
                              String request,
                              String mimeType)
        throws IOException
    {
        OutputStream out = null;

        try
        {
            conn.setRequestProperty("Content-Length",
                                    Integer.toString(request.length()));
            if (mimeType != null)
            {
                conn.setRequestProperty("Content-Type", mimeType);
            }
            if (credentials != null)
            {
                conn.setRequestProperty("Authorization",
                                        "Basic " + credentials);
            }

            // Getting the output stream may flush the headers
            out = conn.openOutputStream();
            int requestLength = request.length();
            for (int i = 0; i < requestLength; ++i)
            {
                out.write(request.charAt(i));
            }
        }
        finally
        {
            if (out != null)
            {
                try
                {
                    out.close();
                }
                catch (IOException e)
                {
                    // already closing, just ignore
                }
            }
        }
    }


    private String readResponse(HttpConnection conn)
        throws IOException
    {
        InputStream in = null;
        String responseStr = null;
        try
        {
            // Opening the InputStream will open the connection
            // and read the HTTP headers. They are stored until
            // requested.
            in = conn.openInputStream();

            // Get the length and process the data
            StringBuffer responseBuf;
            long length = conn.getLength();
            if (length > 0)
            {
                responseBuf = new StringBuffer((int) length);
            }
            else
            {
                // default length
                responseBuf = new StringBuffer();
            }

            int ch;
            while ((ch = in.read()) != -1)
            {
                responseBuf.append((char) ch);
            }
            responseStr = responseBuf.toString();
        }
        finally
        {
            if (in != null)
            {
                try
                {
                    in.close();
                }
                catch (IOException e)
                {
                    // already closing, just ignore
                }
            }
        }
        return responseStr;
    }


    // This is just for tidying up - the instance is useless after it
    // has been called
    void abort()
    {
        aborting = true;
        synchronized (this)
        {
            // wake up our posting thread and kill it
            notify();
        }
    }


    private String getCredentials(String challenge)
        throws IOException
    {
        String realm = getAuthenticationRealm(challenge);
        promptForCredentials(realm);
        if (username == null || password == null)
        {
            throw new IOException("Must give username & password");
        }
        // Calculate the credentials
        return HttpUtils.base64Encode(username + ":" + password);
    }


    private String getAuthenticationRealm(String challenge)
        throws IOException
    {
        if (challenge == null)
        {
            throw new IOException("Missing authentication challenge");
        }
        challenge = challenge.trim();
        if (!challenge.startsWith("Basic"))
        {
            throw new IOException(
              "Authentication scheme not \"Basic\"");
        }
        int length = challenge.length();
        // we don't check for extra double quotes...
        if ((length < 8) ||
            (!challenge.substring(5, 13).equals(" realm=\"")) ||
            (challenge.charAt(length - 1) != '\"'))
        {
            throw new IOException("Authentication realm syntax error");
        }
        return challenge.substring(13, length - 1);
    }



    private void promptForCredentials(String realm)
    {
        // This is a nasty method, as it must suspend the current
        // thread, put up a prompt dialog, get the result, and wake
        // up again
        PromptDialog dialog = new PromptDialog(display, realm);
        dialog.promptForInput();
        // this call blocks us until answered
        username = dialog.getUsername();
        password = dialog.getPassword();
    }


    private class HttpRequest
    {
        String type;
        String mimeType;
        String request;
        HttpPosterListener listener;
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
免费久久99精品国产| 奇米四色…亚洲| 亚洲精品一区在线观看| 不卡的av网站| 久久国产麻豆精品| 亚洲精品视频在线| 国产免费久久精品| 日韩免费高清电影| 欧美在线色视频| gogogo免费视频观看亚洲一| 麻豆视频一区二区| 亚洲一区日韩精品中文字幕| 国产日韩欧美综合在线| 日韩亚洲欧美成人一区| 欧美综合一区二区| 91日韩精品一区| 国产乱色国产精品免费视频| 天堂久久久久va久久久久| 综合激情成人伊人| 国产精品美女久久久久av爽李琼| 欧美电影免费观看高清完整版 | **性色生活片久久毛片| 欧美不卡一区二区三区| 欧美日韩亚洲综合在线| 日本道免费精品一区二区三区| 成人一区二区三区中文字幕| 久久激情五月激情| 欧美bbbbb| 奇米在线7777在线精品 | 水野朝阳av一区二区三区| 综合在线观看色| 亚洲天天做日日做天天谢日日欢| 中文一区在线播放| 国产欧美日韩视频一区二区| 26uuu国产在线精品一区二区| 欧美成人三级在线| 欧美zozozo| 2020日本不卡一区二区视频| 欧美va亚洲va香蕉在线| 精品国产乱码久久久久久久久| 91精品国产欧美日韩| 日韩精品一区二区三区在线| 欧美不卡视频一区| 久久综合九色综合欧美就去吻| 精品国产一区二区三区忘忧草 | 天天综合色天天综合| 亚洲国产一区二区三区| 亚洲成人自拍偷拍| 三级亚洲高清视频| 久久99久久久欧美国产| 激情久久五月天| 高清久久久久久| 91麻豆成人久久精品二区三区| 在线欧美小视频| 51精品视频一区二区三区| 日韩一区二区三区三四区视频在线观看| 91精品国产欧美一区二区18| 欧美成人精品福利| 国产精品私人影院| 一区二区三区在线视频播放| 午夜精品久久久久久久久久久| 美女诱惑一区二区| 国产999精品久久| 色哟哟国产精品免费观看| 欧美三级资源在线| 精品国产亚洲一区二区三区在线观看| 国产三级三级三级精品8ⅰ区| 国产精品伦理一区二区| 亚洲综合小说图片| 久久狠狠亚洲综合| 成人性视频免费网站| 精品视频在线免费| 精品日产卡一卡二卡麻豆| 国产精品乱子久久久久| 性做久久久久久免费观看欧美| 老汉av免费一区二区三区| 成人免费高清在线观看| 欧美三级午夜理伦三级中视频| 欧美电视剧在线看免费| 亚洲免费在线观看视频| 日本成人在线不卡视频| 福利电影一区二区三区| 欧美高清视频一二三区 | 亚洲成人手机在线| 极品少妇xxxx偷拍精品少妇| 91色.com| 久久精品一区二区| 一区二区不卡在线播放 | 中文字幕av免费专区久久| 亚洲综合久久av| 国产乱色国产精品免费视频| 欧美私人免费视频| 日本一区二区三区久久久久久久久不 | 91精品黄色片免费大全| 国产欧美日本一区视频| 日本欧美一区二区三区乱码| www.一区二区| 欧美va日韩va| 五月婷婷综合在线| 99久久久精品| 久久色中文字幕| 性做久久久久久久久| 不卡视频在线看| 日韩精品一区二区三区在线播放| 亚洲精品一二三四区| 国产电影一区在线| 日韩一级二级三级| 亚洲人成精品久久久久久 | 91福利国产成人精品照片| 久久午夜羞羞影院免费观看| 午夜久久久久久电影| 成人精品国产福利| 久久综合久久综合久久| 日本亚洲欧美天堂免费| 欧美午夜精品一区二区三区| 成人欧美一区二区三区1314| 国产一本一道久久香蕉| 91精品一区二区三区久久久久久| 亚洲视频 欧洲视频| 国产a视频精品免费观看| 日韩亚洲欧美中文三级| 日韩影院免费视频| 91在线观看美女| 国产精品色哟哟网站| 国产在线精品免费av| 精品久久免费看| 奇米在线7777在线精品| 8x8x8国产精品| 午夜电影网一区| 欧美久久久久久久久久| 午夜电影一区二区三区| 欧美精品在欧美一区二区少妇| 亚洲第一主播视频| 欧美亚洲尤物久久| 亚洲国产综合视频在线观看| 欧美午夜一区二区三区免费大片| 一区二区三区精品在线| 日本久久一区二区三区| 亚洲裸体xxx| 色94色欧美sute亚洲线路一久| 日韩伦理电影网| 色婷婷精品大在线视频| 亚洲午夜私人影院| 欧美精品日日鲁夜夜添| 免费看日韩a级影片| 欧美白人最猛性xxxxx69交| 国产在线精品免费| 欧美国产精品一区| 91免费在线看| 午夜精品福利一区二区蜜股av| 91超碰这里只有精品国产| 久久精品噜噜噜成人88aⅴ| 久久亚洲影视婷婷| www.亚洲色图.com| 玉米视频成人免费看| 欧美日韩不卡视频| 精品在线免费观看| 日本一区二区不卡视频| 在线看不卡av| 久久国产精品色婷婷| 国产午夜精品一区二区| 色女孩综合影院| 毛片av中文字幕一区二区| 日本一区免费视频| 欧美午夜精品久久久| 日本不卡一二三| 国产视频一区在线播放| 色哟哟国产精品| 免费高清成人在线| 国产精品色婷婷| 精品视频999| 国产剧情一区在线| 亚洲激情网站免费观看| 日韩美女在线视频| 91在线免费播放| 日本三级韩国三级欧美三级| 日本一区二区三区久久久久久久久不| 在线免费观看一区| 国产一区二区三区四区五区入口 | 亚洲免费在线看| 日韩午夜激情免费电影| 北条麻妃国产九九精品视频| 日本在线不卡视频一二三区| 中文成人综合网| 91精品黄色片免费大全| 99精品在线观看视频| 美女视频免费一区| 亚洲欧美日韩久久| 日韩欧美成人一区二区| 色婷婷综合久久久中文字幕| 久久99国产精品久久99| 亚洲午夜久久久久久久久电影院| 2021国产精品久久精品| 欧美丰满少妇xxxxx高潮对白| 成人毛片在线观看| 蜜臀va亚洲va欧美va天堂 | 亚洲综合久久av| 国产精品萝li| 久久综合精品国产一区二区三区| 在线观看日韩精品|