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

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

?? wintransportagent.cpp

?? funambol windows mobile plugin source code, the source code is taken from the funambol site
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
/*
 * Copyright (C) 2003-2007 Funambol, Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY, TITLE, NONINFRINGEMENT or FITNESS FOR A PARTICULAR
 * PURPOSE.  See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 * 02111-1307  USA
 */

/*
 How to test SSL connections
 ----------------------------

 On the server:
 1) create the keystore:
    %JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA
 2) In $CATALINA_HOME/conf/server.xml uncomment the lines:
    <Connector className="org.apache.catalina.connector.http.HttpConnector"
               port="8443" minProcessors="5" maxProcessors="75"
               enableLookups="true"
               acceptCount="10" debug="0" scheme="https" secure="true">
      <Factory className="org.apache.catalina.net.SSLServerSocketFactory" clientAuth="false" protocol="TLS"/>
    </Connector>
 2) Export the certificate from the key store:
    %JAVA_HOME%\bin\keytool -export -alias tomcat -file myroot.cer

 On the client:
  [for _WIN32_WCE]
   1)  Copy myroot.cer in a device/emulator directory
   2) Click on it to import the certificate as a trusted CA
  [for WIN32]
   1) Connect (via https) to the server using a web-browser (type "https://<server_address>:8443)
   2) Accept and install the certificate sent from the server
*/

#include "base/Log.h"
#include "base/messages.h"
#include "base/util/utils.h"
#include "http/constants.h"
#include "http/errors.h"
#include "http/WinTransportAgent.h"
#include "spdm/spdmutils.h"
#include "event/FireEvent.h"
#include "base/util/StringBuffer.h"

#ifdef _WIN32_WCE
#include "http/GPRSConnection.h"
#endif


#define ENTERING(func) // LOG.debug("Entering %ls", func);
#define EXITING(func)  // LOG.debug("Exiting %ls", func);

#ifdef USE_ZLIB
#include "zlib.h"
#endif

/**
 * Constructor.
 * In this implementation newProxy is ignored, since proxy configuration
 * is taken from the WinInet subsystem.
 *
 * @param url    the url where messages will be sent with sendMessage()
 * @param proxy  proxy information or NULL if no proxy should be used
 */
WinTransportAgent::WinTransportAgent(URL& newURL, Proxy& newProxy,
                                     unsigned int maxResponseTimeout,
                                     unsigned int maxmsgsize)
                                     // Use base class constructor to initialize common attributes
                                     : TransportAgent(newURL,
                                     newProxy,
                                     maxResponseTimeout,
                                     maxmsgsize) {

    if (maxResponseTimeout == 0) {
        setTimeout(DEFAULT_MAX_TIMEOUT);
    } else {
        setTimeout(maxResponseTimeout);
    }

    isToDeflate    = FALSE;
    isFirstMessage = TRUE;
    isToInflate    = FALSE;

#ifdef _WIN32_WCE
    // used by default. check connection before...
    if (!EstablishConnection()) {

#  ifdef WIN32_PLATFORM_PSPC
        lastErrorCode = ERR_INTERNET_CONNECTION_MISSING;
        sprintf(lastErrorMsg, "%s: %d",
            "Internet Connection Missing",
            ERR_INTERNET_CONNECTION_MISSING);
#  else
        LOG.error("Warning: internet connection missing.");
#  endif  // #ifdef WIN32_PLATFORM_PSPC
    }
#endif  // #ifdef _WIN32_WCE

}

WinTransportAgent::~WinTransportAgent(){}



/*
 * Sends the given SyncML message to the server specified
 * by the install property 'url'. Returns the server's response.
 * The response string has to be freed with delete [].
 * In case of an error, NULL is returned and lastErrorCode/Msg
 * is set.
 */
char* WinTransportAgent::sendMessage(const char* msg) {

    ENTERING(L"TransportAgent::sendMessage");

#ifdef USE_ZLIB
    // This is the locally allocated buffer for the compressed message.
    // Must be deleted after send.
    Bytef* compr   = NULL;
    WCHAR* wbuffer = NULL;
    WCHAR* buffer  = NULL;
#endif

    char* bufferA = new char[readBufferSize+1];
    int status = -1;
    unsigned int contentLength = 0;
    WCHAR* wurlHost      = NULL;
    WCHAR* wurlResource  = NULL;
    char*  p             = NULL;
    char*  response      = NULL;

    HINTERNET inet       = NULL,
              connection = NULL,
              request    = NULL;


    // Check sending msg and host.
    if (!msg) {
        lastErrorCode = ERR_NETWORK_INIT;
        sprintf(lastErrorMsg, "TransportAgent::sendMessage error: NULL message.");
        goto exit;
    }
    if (!(url.host) || strlen(url.host) == 0) {
        lastErrorCode = ERR_HOST_NOT_FOUND;
        sprintf(lastErrorMsg, "TransportAgent::sendMessage error: %s.", ERRMSG_HOST_NOT_FOUND);
        goto exit;
    }

    DWORD size  = 0,
          read  = 0,
          flags = INTERNET_FLAG_RELOAD |
                  INTERNET_FLAG_NO_CACHE_WRITE |
                  INTERNET_FLAG_KEEP_CONNECTION |           // This is necessary if authentication is required.
                  INTERNET_FLAG_NO_COOKIES;                 // This is used to avoid possible server errors on successive sessions.

	LPCWSTR acceptTypes[2] = {TEXT("*/*"), NULL};


    // Set flags for secure connection (https).
    if (url.isSecure()) {
        flags = flags
              | INTERNET_FLAG_SECURE
              | INTERNET_FLAG_IGNORE_CERT_CN_INVALID
              | INTERNET_FLAG_IGNORE_CERT_DATE_INVALID
              ;
    }


    //
    // Open Internet connection.
    //
    WCHAR* ua = toWideChar(userAgent);
    inet = InternetOpen (ua, INTERNET_OPEN_TYPE_PRECONFIG, NULL, 0, 0);
	if (ua) {delete [] ua; ua = NULL; }

    if (!inet) {
        lastErrorCode = ERR_NETWORK_INIT;
        DWORD code = GetLastError();
        char* tmp = createHttpErrorMessage(code);
        sprintf (lastErrorMsg, "InternetOpen Error: %d - %s", code, tmp);
		delete [] tmp;
        goto exit;
    }
    LOG.debug("Connecting to %s:%d", url.host, url.port);


    //
    // Open an HTTP session for a specified site by using lpszServer.
    //
    wurlHost = toWideChar(url.host);
    if (!(connection = InternetConnect (inet,
                                        wurlHost,
                                        url.port,
                                        NULL, // username
                                        NULL, // password
                                        INTERNET_SERVICE_HTTP,
                                        0,
                                        0))) {
        lastErrorCode = ERR_CONNECT;
        DWORD code = GetLastError();
        char* tmp = createHttpErrorMessage(code);
        sprintf (lastErrorMsg, "InternetConnect Error: %d - %s", code, tmp);
        delete [] tmp;
        goto exit;
    }
    LOG.debug("Requesting resource %s", url.resource);

    //
    // Open an HTTP request handle.
	//
    wurlResource = toWideChar(url.resource);
    if (!(request = HttpOpenRequest (connection,
                                     METHOD_POST,
                                     wurlResource,
                                     HTTP_VERSION,
                                     NULL,
                                     acceptTypes,
                                     flags, 0))) {
        lastErrorCode = ERR_CONNECT;
        DWORD code = GetLastError();
        char* tmp = createHttpErrorMessage(code);
        sprintf (lastErrorMsg, "HttpOpenRequest Error: %d - %s", code, tmp);
        delete [] tmp;
        goto exit;
    }


    //
    // Prepares headers
    //
    WCHAR headers[512];
    contentLength = strlen(msg);

    // Msg to send is the original msg by default.
    // If compression is enabled, it will be switched to
    // compr. We don't want to touch this pointer, so
    // it's const (msg is also const).
    const void* msgToSend = (const void*)msg;

#ifdef USE_ZLIB
    if(compression){
        // This is the locally allocated buffer for the compressed message.
        // Must be deleted after send.

	    //
	    // Say the client can accept the zipped content but the first message is clear
	    //
	    if (isFirstMessage || !isToDeflate) {
	        wsprintf(headers, TEXT("Content-Type: %s\r\nContent-Length: %d\r\nAccept-Encoding: deflate"),
	                          SYNCML_CONTENT_TYPE, contentLength);
	        isFirstMessage = false;
	    }
	    else if (isToDeflate) {
	        //
	        // DEFLATE (compress data)
	        //
	        uLong comprLen = contentLength;
	        compr = new Bytef[contentLength];
	
	        // Compresses the source buffer into the destination buffer.
	        int err = compress(compr, &comprLen, (Bytef*)msg, contentLength);
	        if (err != Z_OK) {
	            lastErrorCode = ERR_HTTP_DEFLATE;
	            sprintf(lastErrorMsg, "ZLIB: error occurred compressing data.");
	            delete [] compr;
	            compr = NULL;
	            goto exit;
	        }
	
	        // Msg to send is the compressed data.
	        msgToSend = (const void*)compr;
	        int uncomprLenght = contentLength;
	        contentLength = comprLen;
	
	        wsprintf(headers, TEXT("Content-Type: %s\r\nContent-Length: %d\r\nAccept-Encoding: deflate\r\nUncompressed-Content-Length: %d\r\nContent-Encoding: deflate"),
	                          SYNCML_CONTENT_TYPE, contentLength, uncomprLenght);
	    }
    }
    else {
        wsprintf(headers, TEXT("Content-Type: %s\r\nContent-Length: %d"), SYNCML_CONTENT_TYPE, contentLength);
    } //end if compression
#else
    wsprintf(headers, TEXT("Content-Type: %s\r\nContent-Length: %d"), SYNCML_CONTENT_TYPE, contentLength);
#endif


    // Timeout to receive a rensponse from server (default = 5 min).
    DWORD timeoutMsec = timeout*1000;
    InternetSetOption(request, INTERNET_OPTION_RECEIVE_TIMEOUT, &timeoutMsec, sizeof(DWORD));


    //
    // Try MAX_RETRIES times to send http request, in case of network errors
    //
    DWORD errorCode = 0;
    int numretries;
    for (numretries=0; numretries < MAX_RETRIES; numretries++) {

        //
        // Send a request to the HTTP server.
        //
        fireTransportEvent(contentLength, SEND_DATA_BEGIN);
        if (!HttpSendRequest(request, headers, wcslen(headers), (LPVOID)msgToSend, contentLength)) {

            errorCode = GetLastError();
            char* tmp = createHttpErrorMessage(errorCode);
            sprintf(lastErrorMsg, "HttpSendRequest error %d: %s", errorCode, tmp);
            LOG.debug(lastErrorMsg);

            if (errorCode == ERROR_INTERNET_OFFLINE_MODE) {                     // 00002 -> retry
                LOG.debug("Offline mode detected: go-online and retry...");
                WCHAR* wurl = toWideChar(url.fullURL);
                InternetGoOnline(wurl, NULL, NULL);
                delete [] wurl;
                continue;
            }
            else if (errorCode == ERROR_INTERNET_TIMEOUT ||                     // 12002 -> out code 2007
                     errorCode == ERROR_INTERNET_INCORRECT_HANDLE_STATE) {      // 12019 -> out code 2007
                lastErrorCode = ERR_HTTP_TIME_OUT;
                sprintf(lastErrorMsg, "Network error: the request has timed out -> exit.");
                LOG.debug(lastErrorMsg);
                goto exit;
            }
            else if (errorCode == ERROR_INTERNET_CANNOT_CONNECT) {              // 12029 -> out code 2001
                lastErrorCode = ERR_CONNECT;
                sprintf(lastErrorMsg, "Network error: the attempt to connect to the server failed -> exit");
                LOG.debug(lastErrorMsg);
                goto exit;
            }
            // Other network error: retry.
            LOG.info("Network error writing data from client: retry %i time...", numretries + 1);
            continue;
        }

        LOG.debug(MESSAGE_SENT);
        fireTransportEvent(contentLength, SEND_DATA_END);


        //
        // Check the status code.
        //
        size = sizeof(status);
        HttpQueryInfo (request,
                       HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER,
                       (LPDWORD)&status,
                       (LPDWORD)&size,
                       NULL);

        // OK: status 200
        if (status == HTTP_STATUS_OK) {
        	LOG.debug("Data sent succesfully to server. Server responds OK");
            break;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产成人鲁色资源国产91色综| 久久久精品免费免费| 亚洲精品成人天堂一二三| 懂色av中文字幕一区二区三区| xnxx国产精品| 成人性生交大片免费看中文 | 6080午夜不卡| 日本一不卡视频| 久久婷婷色综合| 成人激情开心网| 一区二区三区四区中文字幕| 7777精品伊人久久久大香线蕉经典版下载 | 粉嫩欧美一区二区三区高清影视| 中文字幕一区日韩精品欧美| 色视频欧美一区二区三区| 亚洲一二三四久久| 欧美一二区视频| 成人av综合一区| 天天影视色香欲综合网老头| 欧美成人video| a美女胸又www黄视频久久| 亚洲一区二区三区自拍| 日韩三级中文字幕| a4yy欧美一区二区三区| 亚洲韩国一区二区三区| 精品久久人人做人人爱| 色综合视频在线观看| 日韩高清不卡在线| 国产精品久久久久一区二区三区共| 欧美网站一区二区| 国产又黄又大久久| 亚洲一区免费视频| 精品国产乱码久久久久久浪潮| 91网上在线视频| 久久国产欧美日韩精品| 中文字幕一区免费在线观看| 日韩你懂的电影在线观看| www.欧美精品一二区| 日欧美一区二区| 亚洲乱码国产乱码精品精的特点| 日韩视频一区在线观看| 91黄色小视频| 国产成人av资源| 免费国产亚洲视频| 自拍偷拍国产亚洲| 2024国产精品| 777奇米四色成人影色区| 99久久婷婷国产| 韩国视频一区二区| 亚洲成人av在线电影| 国产精品色哟哟| 久久亚洲欧美国产精品乐播| 欧美曰成人黄网| 91在线国内视频| 国产精品影视网| 麻豆久久一区二区| 亚洲成av人片在线观看无码| 亚洲品质自拍视频| 国产人成亚洲第一网站在线播放| 欧美一级片在线观看| 欧美丝袜自拍制服另类| 91福利视频久久久久| proumb性欧美在线观看| 国产一区二区视频在线播放| 日韩福利电影在线| 午夜精品久久一牛影视| 亚洲国产精品综合小说图片区| 亚洲欧美一区二区三区孕妇| 亚洲欧洲精品天堂一级| 国产精品午夜电影| 久久久精品欧美丰满| 精品国产第一区二区三区观看体验| 在线成人免费观看| 欧美亚洲动漫制服丝袜| 在线免费观看日韩欧美| 一本大道久久a久久精二百| 成人三级在线视频| 国产成人三级在线观看| 国产自产视频一区二区三区| 美国毛片一区二区| 美女mm1313爽爽久久久蜜臀| 激情五月婷婷综合| 精品一区二区三区免费观看| 国产精品一区二区91| 国产91精品久久久久久久网曝门| 国产不卡在线播放| 不卡av免费在线观看| 色综合视频一区二区三区高清| 91久久免费观看| 欧美人与禽zozo性伦| 欧美一级二级三级乱码| 精品久久一区二区三区| 国产视频一区二区三区在线观看| 国产精品久久久一本精品| 亚洲男人的天堂在线观看| 亚洲午夜精品在线| 男女性色大片免费观看一区二区| 久久不见久久见免费视频1| 国产乱理伦片在线观看夜一区| 大胆亚洲人体视频| 在线亚洲一区二区| 91麻豆精品国产91久久久| 精品国产三级电影在线观看| 中文字幕制服丝袜一区二区三区| 亚洲五码中文字幕| 日本在线不卡一区| 国产成人精品午夜视频免费 | 日韩成人精品视频| 精品一区二区三区在线视频| 成人免费精品视频| 91福利视频久久久久| 欧美一区二区福利视频| 中文字幕乱码亚洲精品一区| 香蕉久久夜色精品国产使用方法| 老汉av免费一区二区三区| av午夜精品一区二区三区| 欧美日本精品一区二区三区| 国产三级精品三级| 亚洲一区二区三区中文字幕| 国模套图日韩精品一区二区| 一本色道亚洲精品aⅴ| 日韩西西人体444www| 国产精品久久久久aaaa| 五月婷婷综合在线| 国产成人免费网站| 欧美视频日韩视频| 久久久久9999亚洲精品| 午夜精品影院在线观看| 成人免费观看男女羞羞视频| 日韩欧美中文字幕精品| 1000精品久久久久久久久| 日韩高清一区二区| 色综合一个色综合| 久久亚洲私人国产精品va媚药| 亚洲二区在线视频| 高清国产午夜精品久久久久久| 欧美一二三区在线| 亚洲一区成人在线| 成人av免费在线| 精品成人佐山爱一区二区| 亚洲第一狼人社区| 99国产精品久久久久久久久久久 | 国产欧美日韩卡一| 免费在线成人网| 欧美自拍偷拍午夜视频| 国产精品久久久久永久免费观看 | 欧美日韩国产高清一区二区三区| 国产精品夫妻自拍| 九九国产精品视频| 欧美片在线播放| 亚洲一区二区三区四区在线免费观看 | 日韩写真欧美这视频| 亚洲国产日日夜夜| 99re8在线精品视频免费播放| 久久影院视频免费| 日韩—二三区免费观看av| 一本到高清视频免费精品| 中文字幕亚洲视频| 国产成人亚洲综合a∨婷婷| 欧美videos大乳护士334| 天天色图综合网| 在线播放日韩导航| 亚洲一区二区三区国产| 91色|porny| 一区二区日韩av| 在线中文字幕一区二区| 亚洲激情中文1区| 欧美在线999| 午夜精品123| 欧美狂野另类xxxxoooo| 婷婷成人综合网| 日韩视频一区二区| 激情成人综合网| 久久久噜噜噜久久中文字幕色伊伊 | 久久综合九色综合97_久久久| 久久99国产精品免费| 久久影院午夜论| 国产激情一区二区三区四区| 中文字幕精品一区二区三区精品| 不卡av在线免费观看| 亚洲黄网站在线观看| 欧美日韩国产免费一区二区 | 国产丶欧美丶日本不卡视频| 国产精品女主播av| 91捆绑美女网站| 亚洲在线视频免费观看| 欧美一区二区三区视频| 国产麻豆成人传媒免费观看| 国产精品久久久爽爽爽麻豆色哟哟 | 午夜影院久久久| 精品精品国产高清a毛片牛牛| 国产福利视频一区二区三区| 国产精品热久久久久夜色精品三区| 一本大道久久a久久精品综合| 亚洲va欧美va国产va天堂影院| 欧美一区二区三区四区视频| 成人午夜免费视频| 亚洲夂夂婷婷色拍ww47| 精品福利在线导航| 99久久精品一区|