• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            隨筆 - 298  文章 - 377  trackbacks - 0
            <2007年8月>
            2930311234
            567891011
            12131415161718
            19202122232425
            2627282930311
            2345678

            常用鏈接

            留言簿(34)

            隨筆分類

            隨筆檔案

            文章檔案

            相冊

            收藏夾

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            以下是兩個文件:HttpClient.h HttpClient.cpp 一個類
            (錯誤檢測部分沒有加入)
            使用方法
            1:get方式
            CHttpClient conn;
            CString value="value=conn.doGet(value);
            2:post方式
            CHttpClient conn;
            CString value="
            conn.addParam("name1","value1");
            conn.addParam("name2","value2");
            conn.addParam("name3","value3");
            conn.addParam("name4","value4");
            conn.addParam("name5","value5");
            conn.addParam("name6","value6");
            value=conn.doPost(value);

            // HttpClient.h: interface for the CHttpClient class.
            //
            //////////////////////////////////////////////////////////////////////

            #if !defined(AFX_HTTPCLIENT_H__EA769DCB_AAB9_47CD_BD87_FBD6913592C5__INCLUDED_)
            #define AFX_HTTPCLIENT_H__EA769DCB_AAB9_47CD_BD87_FBD6913592C5__INCLUDED_

            #if _MSC_VER > 1000
            #pragma once
            #endif // _MSC_VER > 1000
            #include "wininet.h"
            #include "afxinet.h"
            class CHttpClient
            {
            public:
            void addParam(CString name,CString value);
            CString doPost(CString href);
            CString doGet(CString href);
            CHttpClient();
            virtual ~CHttpClient();

            private:
            CString CONTENT;
            int CL;
            CStringList values;
            CStringList names;
            };

            #endif // !defined(AFX_HTTPCLIENT_H__EA769DCB_AAB9_47CD_BD87_FBD6913592C5__INCLUDED_)

            ++++++++++++++++++++++++++++++++++++++


            // HttpClient.cpp: implementation of the CHttpClient class.
            //
            //////////////////////////////////////////////////////////////////////

            #include "stdafx.h"
            #include "emailsenderv2.h"
            #include "HttpClient.h"

            #ifdef _DEBUG
            #undef THIS_FILE
            static char THIS_FILE[]=__FILE__;
            #define new DEBUG_NEW
            #endif

            //////////////////////////////////////////////////////////////////////
            // Construction/Destruction
            //////////////////////////////////////////////////////////////////////

            CHttpClient::CHttpClient()
            {

            }

            CHttpClient::~CHttpClient()
            {

            }

            CString CHttpClient::doGet(CString href)
            {
            CString httpsource="";
            CInternetSession session1(NULL,0);
            CHttpFile* pHTTPFile=NULL;
            try{
            pHTTPFile=(CHttpFile*)session1.OpenURL(href);
            //session1.
            }catch(CInternetException){
            pHTTPFile=NULL;
            }
            if(pHTTPFile)
            {
            CString text;
            for(int i=0;pHTTPFile->ReadString(text);i++)
            {
            httpsource=httpsource+text+"\r\n";
            }
            pHTTPFile->Close();
            delete pHTTPFile;
            }else
            {

            }
            return httpsource;
            }

            CString CHttpClient::doPost(CString href)
            {
            CString httpsource="";
            CInternetSession session1;
            CHttpConnection* conn1=NULL;
            CHttpFile* pFile = NULL;
            CString strServerName;
            CString strObject;
            INTERNET_PORT nPort;
            DWORD dwServiceType;
            AfxParseURL((LPCTSTR)href,dwServiceType, strServerName, strObject, nPort);
            DWORD retcode;
            char* outBuff = CONTENT.GetBuffer(1000);
            try
            {
            conn1 = session1.GetHttpConnection(strServerName,nPort);
            pFile = conn1->OpenRequest(0,strObject,NULL,1,NULL,"HTTP/1.1",INTERNET_FLAG_EXISTING_CONNECT|INTERNET_FLAG_NO_AUTO_REDIRECT);
            pFile -> AddRequestHeaders("Content-Type: application/x-www-form-urlencoded");
            pFile -> AddRequestHeaders("Accept: */*");
            pFile -> SendRequest(NULL,0,outBuff,strlen(outBuff)+1);
            pFile -> QueryInfoStatusCode(retcode);
            }
            catch (CInternetException * e){};
            if(pFile)
            {
            CString text;
            for(int i=0;pFile->ReadString(text);i++)
            {
            httpsource=httpsource+text+"\r\n";
            }
            pFile->Close();
            }else
            {

            }
            return httpsource;
            delete pFile;
            delete conn1;
            session1.Close();
            }

            void CHttpClient::addParam(CString name, CString value)
            {
            names.AddTail((LPCTSTR)name);
            values.AddTail((LPCTSTR)value);
            CString eq="=";
            CString an="&";
            CONTENT=CONTENT+name+eq+value+an;
            CL=CONTENT.GetLength();
            }


            FeedBack:
            # re: VC實現(xiàn)HTTP協(xié)議的GET和POST方法 2013-03-02 17:15 愛問
            Httpwatch studio 獲取的數(shù)據(jù)
            /*****************Stream************************/
            POST /s HTTP/1.1
            Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/xaml+xml, application/vnd.ms-xpsdocument, application/x-ms-xbap, application/x-ms-application, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
            Referer: http://cet.99sushe.com/
            Accept-Language: zh-cn
            Content-Type: application/x-www-form-urlencoded
            UA-CPU: x86
            Accept-Encoding: gzip, deflate
            User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; InfoPath.2)
            Host: cet.99sushe.com
            Content-Length: 36
            Connection: Keep-Alive
            Cache-Control: no-cache
            Cookie: CNZZDATA30023677=cnzz_eid%3D1415864779-1362203966-http%253A%252F%252Fcet.99sushe.com%26ntime%3D1362210264%26cnzz_a%3D4%26retime%3D1364214548375%26sin%3D%26ltime%3D1362210545355%26rtime%3D0; searchtime=1362210583

            id=372121122201234&name=%CF%F6%C0%66

            /**************************************/
            像這樣的數(shù)據(jù)應該怎么用POST提交呀?
            searchtime如何獲取?
            name這樣的代碼又是什么代碼?怎么轉(zhuǎn)換?
            菜鳥一枚,詳細解釋下吧!非常感謝!
              回復  更多評論
              
            # re: VC實現(xiàn)HTTP協(xié)議的GET和POST方法[未登錄] 2013-09-27 18:56 mark
            非常好。  回復  更多評論
              
            蜜桃麻豆www久久国产精品| 亚洲а∨天堂久久精品9966| 午夜精品久久久内射近拍高清| 久久精品国产黑森林| 色婷婷综合久久久中文字幕| 亚洲乱码精品久久久久.. | 精品国产乱码久久久久久郑州公司 | 91麻豆国产精品91久久久| 偷窥少妇久久久久久久久| 久久精品成人国产午夜| 久久精品中文字幕大胸| 亚洲中文字幕无码久久综合网| 久久久av波多野一区二区| 亚洲v国产v天堂a无码久久| 亚洲va久久久噜噜噜久久 | 欧美亚洲国产精品久久| 久久中文字幕人妻丝袜| 久久久精品国产亚洲成人满18免费网站| 亚洲va中文字幕无码久久| 亚洲精品无码久久久久久| 无码AV中文字幕久久专区| 日韩精品久久无码人妻中文字幕| 久久性生大片免费观看性| 伊人久久大香线蕉成人| 精品人妻伦九区久久AAA片69| 99久久超碰中文字幕伊人| 精品久久久久久久久久中文字幕| 国产日韩久久久精品影院首页| 久久久久久青草大香综合精品| 国产69精品久久久久APP下载| 久久精品九九亚洲精品| 一级做a爰片久久毛片看看| 2022年国产精品久久久久| 亚洲v国产v天堂a无码久久| 99国产精品久久| 国产精品一区二区久久不卡| 久久这里都是精品| 国产精品免费久久| 青青青国产精品国产精品久久久久 | 久久青青草原精品影院| 久久婷婷五月综合97色一本一本|