0

我的目标是使用 C++/Winsock 登录 vBulletin 论坛。论坛是 forums.randi.org

为此,我一直在嗅探数据包,这是服务器对提供登录详细信息的 POST 请求的响应的标头:

HTTP/1.1 200 OK
Date    Tue, 19 Feb 2013 18:12:52 GMT
Server  Apache/2.0.63 (Unix) mod_ssl/2.0.63 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4 PHP/5.2.8
X-Powered-By    PHP/5.2.8
Set-Cookie  bblastvisit=1361297572; expires=Wed, 19-Feb-2014 18:12:52 GMT; path=/
Set-Cookie  bblastactivity=0; expires=Wed, 19-Feb-2014 18:12:52 GMT; path=/
Set-Cookie  bbwelcomeheaders=1361297572; path=/
Set-Cookie  bbsessionhash=9ad9da23b1399e81772437c3819a2501; path=/; HttpOnly
Cache-Control   private
Pragma  private
X-UA-Compatible IE=7
Content-Encoding    gzip
Content-Length  2152
Connection  close
Content-Type    text/html; charset=ISO-8859-1

我的问题是我一直试图阅读响应的内容无济于事。如标题所示,内容的长度应为 2152 字节。我确实将 2152 个字节读入了一些缓冲区,但它们是乱码(而响应标头看起来非常好)。同时,我的嗅探器(HttpFox,一个 Firefox 插件)显示了一个完全合法的内容,但其大小远大于指示的 2152 字节(大约 5900 字节)。

成功登录后由嗅探器检索的内容如下。我想知道如何使用 winsock 读取此内容,为什么这比标题中指示的 Content-Length 长得多。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- BEGIN TEMPLATE: STANDARD_REDIRECT -->

<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">
<head>

<!-- Tapatalk Detect Start -->
<script type="text/javascript">
var tapatalk_iphone_msg = "This forum has an app for iPhone and iPod Touch! Click OK to learn more about Tapatalk.";
var tapatalk_iphone_url = "http://itunes.apple.com/us/app/tapatalk-forum-app/id307880732?mt=8";
var tapatalk_ipad_msg = "This forum has an app for iPad! Click OK to learn more about Tapatalk.";
var tapatalk_ipad_url = "http://itunes.apple.com/us/app/tapatalk-hd-for-ipad/id481579541?mt=8";
var tapatalk_kindle_msg = "This forum has an app for Kindle Fire! Click OK to learn more about Tapatalk.";
var tapatalk_kindle_url = "http://www.amazon.com/gp/mas/dl/android?p=com.quoord.tapatalkpro.activity";
var tapatalk_android_msg = "This forum has an app for Android. Click OK to learn more about Tapatalk.";
var tapatalk_android_url = "market://details?id=com.quoord.tapatalkpro.activity";
var tapatalk_chrome_enable = true;
var tapatalkdir = "mobiquo";
</script>
<script type="text/javascript" src="http://forums.randi.org/mobiquo/tapatalkdetect.js"></script>
<!-- Tapatalk Detect End -->

<!-- BEGIN TEMPLATE: headinclude -->
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="generator" content="vBulletin 3.7.7" />

<meta name="keywords" content="randi, amazing, jref, skeptic, pigasus, debunk, critical thinking, lecture, geller, dowsing, cold reading, cottingley, weird things, paranormal, million dollar challenge, magic, faith healer, nostradamus, fraud, hoax, occult, supernatural, conjuring, uri geller, yuri, flim flam, psychics, john edward, sylvia browne, clock, van praagh,vbulletin,forum,bbs,discussion,jelsoft,bulletin board, psi, amazing meeting" />
<meta name="description" content="The JREF Forum is provided by the James Randi Educational Foundation, a non-profit educational organisation whose goals include promoting critical thinking everywhere, go to http://forums.randi.org/." />


<!-- CSS Stylesheet -->
<style type="text/css" id="vbulletin_css">
/**
* vBulletin 3.7.7 CSS
* Style: 'JREF'; Style ID: 23
*/
@import url("clientscript/vbulletin_css/style-f5050f4f-00023.css");
</style>
<link rel="stylesheet" type="text/css" href="clientscript/vbulletin_important.css?v=377" />


<!-- / CSS Stylesheet -->

<script type="text/javascript" src="http://yui.yahooapis.com/2.9.0/build/yahoo-dom-event/yahoo-dom-event.js?v=377"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.9.0/build/connection/connection-min.js?v=377"></script>
<script type="text/javascript">
<!--
var SESSIONURL = "";
var SECURITYTOKEN = "guest";
var IMGDIR_MISC = "http://forums.randi.org/helloworld2/misc";
var vb_disable_ajax = parseInt("0", 10);
// -->
</script>
<script type="text/javascript" src="clientscript/vbulletin_global.js?v=377"></script>
<script type="text/javascript" src="clientscript/vbulletin_menu.js?v=377"></script>


    <link rel="alternate" type="application/rss+xml" title="JREF Forum RSS Feed" href="external.php?type=RSS2" />





<!-- END TEMPLATE: headinclude -->
<title>JREF Forum</title>
</head>
<body>

<br />
<br />
<br />
<br />

<form action="http://forums.randi.org/forumindex.php" method="post" name="postvarform">
<div style="width: 70%; margin: 0 auto;">
<table class="tcat-rounded" cellpadding="0" cellspacing="0" border="0" width="100%" align="center">
    <tr>
        <td width="10" class="tcat-rounded-left"><img src="http://forums.randi.org/helloworld2/misc/spacer.gif" width="10" height="28" border="0" alt="" /></td>

    <td class="tcat">Redirecting...</td>
        <td width="10" class="tcat-rounded-right"><img src="http://forums.randi.org/helloworld2/misc/spacer.gif" width="10" height="28" border="0" alt="" /></td>
    </tr>
</table>
</div>
<table class="tborder" cellpadding="6" cellspacing="1" border="0" width="70%" align="center">
<tr>
    <td class="panelsurround" align="center">
    <div class="panel">

        <blockquote>
            <p>&nbsp;</p>
            <p><strong>Thank you for logging in, XXXX.</strong></p>

                <p class="smallfont"><a href="http://forums.randi.org/forumindex.php">Click here if your browser does not automatically redirect you.</a></p>
                <div>&nbsp;</div>

        </blockquote>

    </div>
    </td>
</tr>
</table>
</div>
</form>



<noscript>
<meta http-equiv="Refresh" content="2; URL=http://forums.randi.org/forumindex.php" />
</noscript>

<script type="text/javascript">
<!--
function exec_refresh()
{
    window.status = "Redirecting..." + myvar;
    myvar = myvar + " .";
    var timerID = setTimeout("exec_refresh();", 100);
    if (timeout > 0)
    {
        timeout -= 1;
    }
    else
    {
        clearTimeout(timerID);
        window.status = "";
        window.location = "http://forums.randi.org/forumindex.php";
    }
}

var myvar = "";
var timeout = 20;
exec_refresh();
//-->
</script>



</body>
</html>
<!-- END TEMPLATE: STANDARD_REDIRECT -->
4

1 回答 1

0

I think the 2152 bytes are reffered to the gzipped data sent (look at the Content-Encoding gzip header) while HttpFox show you the data already un-gzipped.

于 2013-02-19T20:50:36.790 回答