`
lzj0470
  • 浏览: 1273585 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

HttpClient Cookies

阅读更多
简介



HttpClient支持自动管理Cookies,允许服务端设定Cookies,并在请求时自动返回客户端的Cookies信息。客户端也可以手动的设置Cookies发送到服务端。



不幸的是,同一时间内有太多的Cookies标准: Netscape Cookie, RFC2109, RFC2965 以及大量供应商不符合规范的自定义Cookies标准。针对此,HttpClient提供Cookies管理策略驱动。这片文章意在阐述怎么样去使用不同标准的Cookies以及如何解决在使用Cookies和HttpClient时一些共同的问题。



支持的规格



以下Cookies标准,HttpClient3.1可以支持。



RFC2109



RFC2109是W3C组织第一次推出的官方Cookies标准。理论上,所有使用版本1Cookies的服务端都应该使用此标准。HttpClient已经将此标准设定为默认。



遗憾的是,许多服务端不正确的实现了标准或者仍然使用Netscape标准。所有有时感到此标准太多于严格。



RFC2109是HttpClient使用的默认Cookies协议。



RFC2965



RFC2965定义了版本2并且尝试去弥补在版本1中Cookie的RFC2109标准的缺点。RFC2965是,并规定RFC2965最终取代RFC2109.



发送RFC2965标准Cookies的服务端,将会使用Set-Cookie2 header添加到Set-Cookie Header信心中,RFC2965 Cookies是区分端口的。



Netscape标准



Netscape是最原始的Cookies规范,同时也是RFC2109的基础。尽管如此,还是在很多重要的方面与RFC2109不同,可能需要特定服务器才可以兼容。



Browser Compatibility



这种兼容性设计要求是适应尽可能多的不同的服务器,尽管不是完全按照标准来实现的。如果你遇到了解析Cookies的问题,你就可能要用到这一个规范。



有太多的web站点是用CGI脚本去实现的,而导致只有将所有的Cookies都放入Request header才可以正常的工作。这种情况下最好设置http.protocol.single-cookie-header参数为true。



Ignore Cookies



此规格忽略所有Cookie 。被用来防止HttpClient接受和发送的Cookie。



Spacifying the Specification



有俩中方式去规定使用哪种Cookies规范,每个HttpMethod实例都有HttpMethodParams,他的policy值必须使用方法CookiePolicy.registerCookieSpec()来注册。



HttpMethod method = new GetMethod();

Method.getParams().setCookiePolicy(CookiePolicy.RFC_2109);



手动处理Cookies



HttpClient的Cookie管理API可以手动处理Cookie。可以手动设置Requset的Cookie headers或是处理Response的Set-Cookie的headers或是用自动Cookie管理去代替。



HttpMethod method = new GetMethod();

Method.getParams().setCookiePolicy(CookiePolicy.IGNORE_COOKIES);

Method.setRequestHeader(“Cookie”, “special_cookie=value”);
分享到:
评论
5 楼 a_10jqka_2010 2012-04-21  
这个数组就是 HTTP 命令中的文本命令的 Hex 化,之所以这样是因为以字符形式录入变量,代码不是很规整。若有兴趣可装入内存试试。

"模拟登录"这活可深可浅,若再加上 HTTTS 或者什么别的验证体系,那就很消耗精力了!
4 楼 lzj0470 2012-04-21  
a_10jqka_2010 写道
好久没来 iteye 了,都忘了回复顺序了,排版有些错位,不知是否方面阅读

呵呵,没看出来是怎么操作的哦。不过思想上是可以讨论的。我没有象你这样操作吧。目前我是运用在模拟登陆这块。
3 楼 a_10jqka_2010 2012-04-21  
好久没来 iteye 了,都忘了回复顺序了,排版有些错位,不知是否方面阅读
2 楼 a_10jqka_2010 2012-04-21  
int build_POST_126Cnt_CMD(  char *pFileName,   char *pFileBuf, int bufLen,
    char *pSID,    int   sidLen,
char *pComposeID,  int   composeIDLen,
char *pCookieCore, int cookieCoreLen,
char *pAttBody,    int attBodyIndex[][2],
char *pCookie,     int   cookieLen,
char *pAnswer,     int   &ansLen
)
{
int answer     = 0x00, t_ContentLen, temI, t_Single, t_Loop;
char t_Room[64] = { 0x00 };

t_ContentLen = 0x00;
for ( temI=attBodyIndex[0][0]; temI<=attBodyIndex[0][1]; temI++ )
{
t_ContentLen += ( attBodyIndex[temI][1] - attBodyIndex[temI][0] );
}
t_ContentLen += 2 * strlen(pFileName) + bufLen;

sprintf( t_Room, "%d", t_ContentLen );


char *t_Hash[][2] = { { pAttBody + attBodyIndex[1][0],  (char*)(attBodyIndex[1][1] - attBodyIndex[1][0])   },
{ pSID,   (char*)(sidLen)      },
{ pAttBody + attBodyIndex[2][0],  (char*)(attBodyIndex[2][1] - attBodyIndex[2][0])   },
{ pComposeID,   (char*)(composeIDLen)      },
{ pAttBody + attBodyIndex[3][0],  (char*)(attBodyIndex[3][1] - attBodyIndex[3][0])   },
{ pCookieCore,   (char*)(cookieCoreLen) },
{ pAttBody + attBodyIndex[4][0],  (char*)(attBodyIndex[4][1] - attBodyIndex[4][0])   },
{ t_Room,   (char*)(strlen(t_Room))      },
{ pAttBody + attBodyIndex[5][0],  (char*)(attBodyIndex[5][1] - attBodyIndex[5][0])   },
{ pCookie,   (char*)(cookieLen-1)          },
{ pAttBody + attBodyIndex[6][0],  (char*)(attBodyIndex[6][1] - attBodyIndex[6][0])   },
{ pAttBody + attBodyIndex[7][0],  (char*)(attBodyIndex[7][1] - attBodyIndex[7][0])   },
{ pFileName,   (char*)(strlen(pFileName)) },
{ pAttBody + attBodyIndex[8][0],  (char*)(attBodyIndex[8][1] - attBodyIndex[8][0])   },
{ pFileName,   (char*)(strlen(pFileName)) },
{ pAttBody + attBodyIndex[9][0],  (char*)(attBodyIndex[9][1] - attBodyIndex[9][0])   },
{ pFileBuf,   (char*)(bufLen) },
{ pAttBody + attBodyIndex[10][0], (char*)(attBodyIndex[10][1] - attBodyIndex[10][0]) }

};

t_Loop = sizeof(t_Hash) / sizeof(t_Hash[0]);

ansLen = 0x00;

for ( temI=0; temI<t_Loop; temI++ )
{
t_Single = (int)t_Hash[temI][1];

memcpy( pAnswer + ansLen, t_Hash[temI][0], t_Single );

ansLen += t_Single;
}


return answer;
}

int _126_Att_Template_Index[16][2] = {

{ 7,   10     },

{ 0x0000, 0x0035 }, { 0x0059, 0x0064 }, { 0x0071, 0x0082 }, { 0x00C7, 0x0182 },
{ 0x0185, 0x01C0 }, { 0x07E1, 0x07E5 }, { 0x07E5, 0x0844 }, { 0x084B, 0x08B4 },
{ 0x08BB, 0x08E8 }, { 0x08F5, 0x098E }
};


char _126_Att_Template[2446] = {

0x50, 0x4F, 0x53, 0x54, 0x20, 0x2F, 0x6A, 0x79, 0x33, 0x2F,
0x63, 0x6F, 0x6D, 0x70, 0x6F, 0x73, 0x65, 0x2F, 0x66, 0x6C,
0x61, 0x73, 0x68, 0x55, 0x70, 0x6C, 0x6F, 0x61, 0x64, 0x2E,
0x6A, 0x73, 0x70, 0x3F, 0x66, 0x69, 0x6C, 0x65, 0x54, 0x79,
0x70, 0x65, 0x3D, 0x66, 0x6C, 0x61, 0x73, 0x68, 0x46, 0x69,
0x6C, 0x65, 0x26, 0x73, 0x69, 0x64, 0x3D, 0x41, 0x42, 0x73,
0x4F, 0x4F, 0x67, 0x50, 0x78, 0x6F, 0x70, 0x4A, 0x66, 0x65,
0x48, 0x70, 0x77, 0x45, 0x46, 0x78, 0x78, 0x50, 0x56, 0x4F,
0x65, 0x53, 0x63, 0x56, 0x76, 0x66, 0x57, 0x72, 0x6A, 0x26,
0x43, 0x6F, 0x6D, 0x70, 0x6F, 0x73, 0x65, 0x49, 0x64, 0x3D,
0x31, 0x33, 0x33, 0x33, 0x37, 0x38, 0x32, 0x37, 0x31, 0x34,
0x39, 0x32, 0x38, 0x26, 0x43, 0x6F, 0x6F, 0x6B, 0x69, 0x65,
0x2E, 0x43, 0x6F, 0x72, 0x65, 0x6D, 0x61, 0x69, 0x6C, 0x3D,
0x31, 0x33, 0x33, 0x33, 0x37, 0x38, 0x32, 0x32, 0x35, 0x33,
0x38, 0x34, 0x38, 0x25, 0x32, 0x35, 0x41, 0x42, 0x73, 0x4F,
0x4F, 0x67, 0x50, 0x78, 0x6F, 0x70, 0x4A, 0x66, 0x65, 0x48,
0x70, 0x77, 0x45, 0x46, 0x78, 0x78, 0x50, 0x56, 0x4F, 0x65,
0x53, 0x63, 0x56, 0x76, 0x66, 0x57, 0x72, 0x6A, 0x25, 0x32,
0x35, 0x67, 0x34, 0x61, 0x34, 0x34, 0x2E, 0x6D, 0x61, 0x69,
0x6C, 0x2E, 0x31, 0x32, 0x36, 0x2E, 0x63, 0x6F, 0x6D, 0x20,
0x48, 0x54, 0x54, 0x50, 0x2F, 0x31, 0x2E, 0x31, 0x0D, 0x0A,
0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x3A, 0x20, 0x74, 0x65,
0x78, 0x74, 0x2F, 0x2A, 0x0D, 0x0A, 0x43, 0x6F, 0x6E, 0x74,
0x65, 0x6E, 0x74, 0x2D, 0x54, 0x79, 0x70, 0x65, 0x3A, 0x20,
0x6D, 0x75, 0x6C, 0x74, 0x69, 0x70, 0x61, 0x72, 0x74, 0x2F,
0x66, 0x6F, 0x72, 0x6D, 0x2D, 0x64, 0x61, 0x74, 0x61, 0x3B,
0x20, 0x62, 0x6F, 0x75, 0x6E, 0x64, 0x61, 0x72, 0x79, 0x3D,
0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D,
0x61, 0x65, 0x30, 0x63, 0x48, 0x32, 0x63, 0x48, 0x32, 0x49,
0x6A, 0x35, 0x45, 0x66, 0x31, 0x67, 0x4C, 0x36, 0x4B, 0x4D,
0x37, 0x63, 0x48, 0x32, 0x47, 0x49, 0x33, 0x63, 0x48, 0x32,
0x0D, 0x0A, 0x55, 0x73, 0x65, 0x72, 0x2D, 0x41, 0x67, 0x65,
0x6E, 0x74, 0x3A, 0x20, 0x53, 0x68, 0x6F, 0x63, 0x6B, 0x77,
0x61, 0x76, 0x65, 0x20, 0x46, 0x6C, 0x61, 0x73, 0x68, 0x0D,
0x0A, 0x48, 0x6F, 0x73, 0x74, 0x3A, 0x20, 0x63, 0x77, 0x65,
0x62, 0x6D, 0x61, 0x69, 0x6C, 0x2E, 0x6D, 0x61, 0x69, 0x6C,
0x2E, 0x31, 0x32, 0x36, 0x2E, 0x63, 0x6F, 0x6D, 0x0D, 0x0A,
0x43, 0x6F, 0x6E, 0x74, 0x65, 0x6E, 0x74, 0x2D, 0x4C, 0x65,
0x6E, 0x67, 0x74, 0x68, 0x3A, 0x20, 0x34, 0x32, 0x35, 0x0D,
0x0A, 0x43, 0x6F, 0x6E, 0x6E, 0x65, 0x63, 0x74, 0x69, 0x6F,
0x6E, 0x3A, 0x20, 0x4B, 0x65, 0x65, 0x70, 0x2D, 0x41, 0x6C,
0x69, 0x76, 0x65, 0x0D, 0x0A, 0x43, 0x61, 0x63, 0x68, 0x65,
0x2D, 0x43, 0x6F, 0x6E, 0x74, 0x72, 0x6F, 0x6C, 0x3A, 0x20,
0x6E, 0x6F, 0x2D, 0x63, 0x61, 0x63, 0x68, 0x65, 0x0D, 0x0A,
0x43, 0x6F, 0x6F, 0x6B, 0x69, 0x65, 0x3A, 0x20, 0x4A, 0x53,
0x45, 0x53, 0x53, 0x49, 0x4F, 0x4E, 0x49, 0x44, 0x3D, 0x36,
0x37, 0x41, 0x45, 0x37, 0x38, 0x39, 0x46, 0x42, 0x37, 0x39,
0x41, 0x41, 0x39, 0x34, 0x44, 0x39, 0x45, 0x30, 0x33, 0x30,
0x39, 0x44, 0x43, 0x33, 0x46, 0x42, 0x34, 0x34, 0x31, 0x30,
0x41, 0x3B, 0x20, 0x5F, 0x6E, 0x74, 0x65, 0x73, 0x5F, 0x6E,
0x6E, 0x69, 0x64, 0x3D, 0x33, 0x65, 0x65, 0x31, 0x62, 0x35,
0x31, 0x39, 0x33, 0x37, 0x64, 0x30, 0x33, 0x38, 0x30, 0x39,
0x65, 0x34, 0x32, 0x62, 0x32, 0x37, 0x64, 0x38, 0x39, 0x35,
0x38, 0x32, 0x30, 0x63, 0x61, 0x32, 0x2C, 0x30, 0x3B, 0x20,
0x6E, 0x74, 0x73, 0x5F, 0x6D, 0x61, 0x69, 0x6C, 0x5F, 0x75,
0x73, 0x65, 0x72, 0x3D, 0x61, 0x5F, 0x34, 0x31, 0x34, 0x32,
0x34, 0x33, 0x34, 0x35, 0x34, 0x36, 0x34, 0x37, 0x34, 0x38,
0x34, 0x39, 0x3A, 0x33, 0x3A, 0x31, 0x3B, 0x20, 0x50, 0x5F,
0x49, 0x4E, 0x46, 0x4F, 0x3D, 0x61, 0x5F, 0x34, 0x31, 0x34,
0x32, 0x34, 0x33, 0x34, 0x35, 0x34, 0x36, 0x34, 0x37, 0x34,
0x38, 0x34, 0x39, 0x40, 0x31, 0x32, 0x36, 0x2E, 0x63, 0x6F,
0x6D, 0x7C, 0x31, 0x33, 0x33, 0x33, 0x37, 0x38, 0x32, 0x32,
0x35, 0x34, 0x7C, 0x30, 0x7C, 0x6D, 0x61, 0x69, 0x6C, 0x31,
0x32, 0x36, 0x7C, 0x30, 0x30, 0x26, 0x39, 0x39, 0x7C, 0x62,
0x65, 0x6A, 0x26, 0x31, 0x33, 0x33, 0x33, 0x37, 0x37, 0x36,
0x34, 0x33, 0x38, 0x26, 0x6D, 0x61, 0x69, 0x6C, 0x31, 0x32,
0x36, 0x23, 0x62, 0x65, 0x6A, 0x26, 0x6E, 0x75, 0x6C, 0x6C,
0x23, 0x31, 0x30, 0x23, 0x30, 0x7C, 0x26, 0x30, 0x3B, 0x20,
0x4E, 0x45, 0x54, 0x45, 0x41, 0x53, 0x45, 0x5F, 0x53, 0x53,
0x4E, 0x3D, 0x61, 0x5F, 0x34, 0x31, 0x34, 0x32, 0x34, 0x33,
0x34, 0x35, 0x34, 0x36, 0x34, 0x37, 0x34, 0x38, 0x34, 0x39,
0x3B, 0x20, 0x6E, 0x74, 0x65, 0x73, 0x5F, 0x6D, 0x61, 0x69,
0x6C, 0x5F, 0x66, 0x69, 0x72, 0x73, 0x74, 0x70, 0x61, 0x67,
0x65, 0x3D, 0x6E, 0x6F, 0x72, 0x6D, 0x61, 0x6C, 0x3B, 0x20,
0x6C, 0x6F, 0x3D, 0x25, 0x75, 0x35, 0x33, 0x31, 0x37, 0x25,
0x75, 0x34, 0x45, 0x41, 0x43, 0x25, 0x75, 0x35, 0x45, 0x30,
0x32, 0x3B, 0x20, 0x73, 0x74, 0x61, 0x72, 0x74, 0x74, 0x69,
0x6D, 0x65, 0x3D, 0x31, 0x33, 0x33, 0x33, 0x37, 0x38, 0x32,
0x32, 0x35, 0x36, 0x30, 0x33, 0x37, 0x3B, 0x20, 0x64, 0x66,
0x3D, 0x77, 0x65, 0x62, 0x6D, 0x61, 0x69, 0x6C, 0x31, 0x32,
0x36, 0x3B, 0x20, 0x53, 0x49, 0x44, 0x3D, 0x66, 0x65, 0x65,
0x32, 0x38, 0x34, 0x61, 0x35, 0x2D, 0x66, 0x31, 0x31, 0x64,
0x2D, 0x34, 0x65, 0x63, 0x64, 0x2D, 0x61, 0x30, 0x31, 0x35,
0x2D, 0x30, 0x32, 0x30, 0x31, 0x61, 0x63, 0x33, 0x36, 0x37,
0x66, 0x36, 0x30, 0x3B, 0x20, 0x53, 0x5F, 0x49, 0x4E, 0x46,
0x4F, 0x3D, 0x31, 0x33, 0x33, 0x33, 0x37, 0x38, 0x32, 0x32,
0x35, 0x34, 0x7C, 0x30, 0x7C, 0x23, 0x32, 0x26, 0x31, 0x30,
0x23, 0x7C, 0x61, 0x5F, 0x34, 0x31, 0x34, 0x32, 0x34, 0x33,
0x34, 0x35, 0x34, 0x36, 0x34, 0x37, 0x34, 0x38, 0x34, 0x39,
0x40, 0x31, 0x32, 0x36, 0x2E, 0x63, 0x6F, 0x6D, 0x3B, 0x20,
0x4E, 0x54, 0x45, 0x53, 0x5F, 0x53, 0x45, 0x53, 0x53, 0x3D,
0x6B, 0x70, 0x69, 0x6A, 0x37, 0x5F, 0x30, 0x55, 0x32, 0x59,
0x57, 0x47, 0x54, 0x50, 0x39, 0x6E, 0x70, 0x59, 0x73, 0x5A,
0x78, 0x6E, 0x58, 0x65, 0x57, 0x33, 0x56, 0x6E, 0x36, 0x47,
0x35, 0x39, 0x4F, 0x79, 0x65, 0x6A, 0x64, 0x33, 0x38, 0x6B,
0x58, 0x71, 0x34, 0x54, 0x35, 0x35, 0x45, 0x6F, 0x34, 0x4D,
0x7A, 0x75, 0x4E, 0x4C, 0x34, 0x6C, 0x50, 0x57, 0x76, 0x65,
0x45, 0x76, 0x58, 0x39, 0x41, 0x75, 0x55, 0x58, 0x65, 0x43,
0x75, 0x49, 0x41, 0x74, 0x34, 0x43, 0x34, 0x4F, 0x4C, 0x6D,
0x56, 0x30, 0x6E, 0x38, 0x48, 0x77, 0x4A, 0x30, 0x77, 0x4B,
0x76, 0x6C, 0x6E, 0x6E, 0x7A, 0x59, 0x2E, 0x4A, 0x73, 0x67,
0x7A, 0x47, 0x32, 0x33, 0x69, 0x4C, 0x67, 0x59, 0x35, 0x59,
0x31, 0x75, 0x35, 0x6D, 0x38, 0x4E, 0x67, 0x5A, 0x52, 0x39,
0x39, 0x57, 0x74, 0x32, 0x4A, 0x6C, 0x6E, 0x5F, 0x64, 0x6B,
0x75, 0x77, 0x36, 0x62, 0x62, 0x51, 0x72, 0x6A, 0x78, 0x5F,
0x65, 0x7A, 0x45, 0x6F, 0x5F, 0x36, 0x62, 0x6A, 0x50, 0x62,
0x74, 0x79, 0x5A, 0x57, 0x53, 0x31, 0x65, 0x73, 0x6C, 0x74,
0x4D, 0x59, 0x6A, 0x53, 0x64, 0x57, 0x66, 0x6D, 0x34, 0x62,
0x75, 0x47, 0x7A, 0x3B, 0x20, 0x6D, 0x61, 0x69, 0x6C, 0x5F,
0x75, 0x70, 0x78, 0x3D, 0x74, 0x34, 0x62, 0x6A, 0x2E, 0x6D,
0x61, 0x69, 0x6C, 0x2E, 0x31, 0x32, 0x36, 0x2E, 0x63, 0x6F,
0x6D, 0x7C, 0x74, 0x31, 0x62, 0x6A, 0x2E, 0x6D, 0x61, 0x69,
0x6C, 0x2E, 0x31, 0x32, 0x36, 0x2E, 0x63, 0x6F, 0x6D, 0x7C,
0x74, 0x32, 0x62, 0x6A, 0x2E, 0x6D, 0x61, 0x69, 0x6C, 0x2E,
0x31, 0x32, 0x36, 0x2E, 0x63, 0x6F, 0x6D, 0x7C, 0x74, 0x33,
0x62, 0x6A, 0x2E, 0x6D, 0x61, 0x69, 0x6C, 0x2E, 0x31, 0x32,
0x36, 0x2E, 0x63, 0x6F, 0x6D, 0x3B, 0x20, 0x6D, 0x61, 0x69,
0x6C, 0x5F, 0x68, 0x6F, 0x73, 0x74, 0x3D, 0x63, 0x77, 0x65,
0x62, 0x6D, 0x61, 0x69, 0x6C, 0x2E, 0x6D, 0x61, 0x69, 0x6C,
0x2E, 0x31, 0x32, 0x36, 0x2E, 0x63, 0x6F, 0x6D, 0x3B, 0x20,
0x6D, 0x61, 0x69, 0x6C, 0x5F, 0x64, 0x69, 0x73, 0x74, 0x3D,
0x22, 0x22, 0x3B, 0x20, 0x43, 0x6F, 0x72, 0x65, 0x6D, 0x61,
0x69, 0x6C, 0x3D, 0x31, 0x33, 0x33, 0x33, 0x37, 0x38, 0x32,
0x32, 0x35, 0x33, 0x38, 0x34, 0x38, 0x25, 0x41, 0x42, 0x73,
0x4F, 0x4F, 0x67, 0x50, 0x78, 0x6F, 0x70, 0x4A, 0x66, 0x65,
0x48, 0x70, 0x77, 0x45, 0x46, 0x78, 0x78, 0x50, 0x56, 0x4F,
0x65, 0x53, 0x63, 0x56, 0x76, 0x66, 0x57, 0x72, 0x6A, 0x25,
0x67, 0x34, 0x61, 0x34, 0x34, 0x2E, 0x6D, 0x61, 0x69, 0x6C,
0x2E, 0x31, 0x32, 0x36, 0x2E, 0x63, 0x6F, 0x6D, 0x3B, 0x20,
0x4D, 0x41, 0x49, 0x4C, 0x5F, 0x4D, 0x49, 0x53, 0x43, 0x3D,
0x22, 0x61, 0x5F, 0x34, 0x31, 0x34, 0x32, 0x34, 0x33, 0x34,
0x35, 0x34, 0x36, 0x34, 0x37, 0x34, 0x38, 0x34, 0x39, 0x40,
0x31, 0x32, 0x36, 0x2E, 0x63, 0x6F, 0x6D, 0x22, 0x3B, 0x20,
0x63, 0x6D, 0x5F, 0x6C, 0x61, 0x73, 0x74, 0x5F, 0x69, 0x6E,
0x66, 0x6F, 0x3D, 0x64, 0x54, 0x31, 0x68, 0x58, 0x7A, 0x51,
0x78, 0x4E, 0x44, 0x49, 0x30, 0x4D, 0x7A, 0x51, 0x31, 0x4E,
0x44, 0x59, 0x30, 0x4E, 0x7A, 0x51, 0x34, 0x4E, 0x44, 0x6B,
0x6C, 0x4E, 0x44, 0x41, 0x78, 0x4D, 0x6A, 0x59, 0x75, 0x59,
0x32, 0x39, 0x74, 0x4A, 0x6D, 0x51, 0x39, 0x61, 0x48, 0x52,
0x30, 0x63, 0x43, 0x55, 0x7A, 0x51, 0x53, 0x55, 0x79, 0x52,
0x69, 0x55, 0x79, 0x52, 0x6D, 0x4E, 0x33, 0x5A, 0x57, 0x4A,
0x74, 0x59, 0x57, 0x6C, 0x73, 0x4C, 0x6D, 0x31, 0x68, 0x61,
0x57, 0x77, 0x75, 0x4D, 0x54, 0x49, 0x32, 0x4C, 0x6D, 0x4E,
0x76, 0x62, 0x53, 0x55, 0x79, 0x52, 0x6D, 0x70, 0x35, 0x4D,
0x79, 0x55, 0x79, 0x52, 0x6D, 0x31, 0x68, 0x61, 0x57, 0x34,
0x75, 0x61, 0x6E, 0x4E, 0x77, 0x4A, 0x54, 0x4E, 0x47, 0x63,
0x32, 0x6C, 0x6B, 0x4A, 0x54, 0x4E, 0x45, 0x51, 0x55, 0x4A,
0x7A, 0x54, 0x30, 0x39, 0x6E, 0x55, 0x48, 0x68, 0x76, 0x63,
0x45, 0x70, 0x6D, 0x5A, 0x55, 0x68, 0x77, 0x64, 0x30, 0x56,
0x47, 0x65, 0x48, 0x68, 0x51, 0x56, 0x6B, 0x39, 0x6C, 0x55,
0x32, 0x4E, 0x57, 0x64, 0x6D, 0x5A, 0x58, 0x63, 0x6D, 0x6F,
0x6D, 0x63, 0x7A, 0x31, 0x42, 0x51, 0x6E, 0x4E, 0x50, 0x54,
0x32, 0x64, 0x51, 0x65, 0x47, 0x39, 0x77, 0x53, 0x6D, 0x5A,
0x6C, 0x53, 0x48, 0x42, 0x33, 0x52, 0x55, 0x5A, 0x34, 0x65,
0x46, 0x42, 0x57, 0x54, 0x32, 0x56, 0x54, 0x59, 0x31, 0x5A,
0x32, 0x5A, 0x6C, 0x64, 0x79, 0x61, 0x69, 0x5A, 0x6F, 0x50,
0x57, 0x68, 0x30, 0x64, 0x48, 0x41, 0x6C, 0x4D, 0x30, 0x45,
0x6C, 0x4D, 0x6B, 0x59, 0x6C, 0x4D, 0x6B, 0x5A, 0x33, 0x5A,
0x57, 0x4A, 0x74, 0x59, 0x57, 0x6C, 0x73, 0x4C, 0x6D, 0x31,
0x68, 0x61, 0x57, 0x77, 0x75, 0x4D, 0x54, 0x49, 0x32, 0x4C,
0x6D, 0x4E, 0x76, 0x62, 0x53, 0x55, 0x79, 0x52, 0x6D, 0x70,
0x35, 0x4D, 0x79, 0x55, 0x79, 0x52, 0x6D, 0x31, 0x68, 0x61,
0x57, 0x34, 0x75, 0x61, 0x6E, 0x4E, 0x77, 0x4A, 0x54, 0x4E,
0x47, 0x63, 0x32, 0x6C, 0x6B, 0x4A, 0x54, 0x4E, 0x45, 0x51,
0x55, 0x4A, 0x7A, 0x54, 0x30, 0x39, 0x6E, 0x55, 0x48, 0x68,
0x76, 0x63, 0x45, 0x70, 0x6D, 0x5A, 0x55, 0x68, 0x77, 0x64,
0x30, 0x56, 0x47, 0x65, 0x48, 0x68, 0x51, 0x56, 0x6B, 0x39,
0x6C, 0x55, 0x32, 0x4E, 0x57, 0x64, 0x6D, 0x5A, 0x58, 0x63,
0x6D, 0x6F, 0x6D, 0x64, 0x7A, 0x31, 0x33, 0x5A, 0x57, 0x4A,
0x74, 0x59, 0x57, 0x6C, 0x73, 0x4C, 0x6D, 0x31, 0x68, 0x61,
0x57, 0x77, 0x75, 0x4D, 0x54, 0x49, 0x32, 0x4C, 0x6D, 0x4E,
0x76, 0x62, 0x53, 0x5A, 0x73, 0x50, 0x53, 0x30, 0x78, 0x4A,
0x6E, 0x51, 0x39, 0x4D, 0x79, 0x5A, 0x75, 0x50, 0x57, 0x4D,
0x6D, 0x64, 0x6A, 0x30, 0x77, 0x3B, 0x20, 0x4D, 0x41, 0x49,
0x4C, 0x5F, 0x53, 0x45, 0x53, 0x53, 0x3D, 0x6B, 0x70, 0x69,
0x6A, 0x37, 0x5F, 0x30, 0x55, 0x32, 0x59, 0x57, 0x47, 0x54,
0x50, 0x39, 0x6E, 0x70, 0x59, 0x73, 0x5A, 0x78, 0x6E, 0x58,
0x65, 0x57, 0x33, 0x56, 0x6E, 0x36, 0x47, 0x35, 0x39, 0x4F,
0x79, 0x65, 0x6A, 0x64, 0x33, 0x38, 0x6B, 0x58, 0x71, 0x34,
0x54, 0x35, 0x35, 0x45, 0x6F, 0x34, 0x4D, 0x7A, 0x75, 0x4E,
0x4C, 0x34, 0x6C, 0x50, 0x57, 0x76, 0x65, 0x45, 0x76, 0x58,
0x39, 0x41, 0x75, 0x55, 0x58, 0x65, 0x43, 0x75, 0x49, 0x41,
0x74, 0x34, 0x43, 0x34, 0x4F, 0x4C, 0x6D, 0x56, 0x30, 0x6E,
0x38, 0x48, 0x77, 0x4A, 0x30, 0x77, 0x4B, 0x76, 0x6C, 0x6E,
0x6E, 0x7A, 0x59, 0x2E, 0x4A, 0x73, 0x67, 0x7A, 0x47, 0x32,
0x33, 0x69, 0x4C, 0x67, 0x59, 0x35, 0x59, 0x31, 0x75, 0x35,
0x6D, 0x38, 0x4E, 0x67, 0x5A, 0x52, 0x39, 0x39, 0x57, 0x74,
0x32, 0x4A, 0x6C, 0x6E, 0x5F, 0x64, 0x6B, 0x75, 0x77, 0x36,
0x62, 0x62, 0x51, 0x72, 0x6A, 0x78, 0x5F, 0x65, 0x7A, 0x45,
0x6F, 0x5F, 0x36, 0x62, 0x6A, 0x50, 0x62, 0x74, 0x79, 0x5A,
0x57, 0x53, 0x31, 0x65, 0x73, 0x6C, 0x74, 0x4D, 0x59, 0x6A,
0x53, 0x64, 0x57, 0x66, 0x6D, 0x34, 0x62, 0x75, 0x47, 0x7A,
0x3B, 0x20, 0x73, 0x65, 0x63, 0x75, 0x5F, 0x69, 0x6E, 0x66,
0x6F, 0x3D, 0x30, 0x3B, 0x20, 0x6D, 0x61, 0x69, 0x6C, 0x5F,
0x75, 0x69, 0x64, 0x3D, 0x61, 0x5F, 0x34, 0x31, 0x34, 0x32,
0x34, 0x33, 0x34, 0x35, 0x34, 0x36, 0x34, 0x37, 0x34, 0x38,
0x34, 0x39, 0x40, 0x31, 0x32, 0x36, 0x2E, 0x63, 0x6F, 0x6D,
0x3B, 0x20, 0x43, 0x6F, 0x72, 0x65, 0x6D, 0x61, 0x69, 0x6C,
0x2E, 0x73, 0x69, 0x64, 0x3D, 0x41, 0x42, 0x73, 0x4F, 0x4F,
0x67, 0x50, 0x78, 0x6F, 0x70, 0x4A, 0x66, 0x65, 0x48, 0x70,
0x77, 0x45, 0x46, 0x78, 0x78, 0x50, 0x56, 0x4F, 0x65, 0x53,
0x63, 0x56, 0x76, 0x66, 0x57, 0x72, 0x6A, 0x0D, 0x0A, 0x0D,
0x0A, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D,
0x2D, 0x2D, 0x2D, 0x61, 0x65, 0x30, 0x63, 0x48, 0x32, 0x63,
0x48, 0x32, 0x49, 0x6A, 0x35, 0x45, 0x66, 0x31, 0x67, 0x4C,
0x36, 0x4B, 0x4D, 0x37, 0x63, 0x48, 0x32, 0x47, 0x49, 0x33,
0x63, 0x48, 0x32, 0x0D, 0x0A, 0x43, 0x6F, 0x6E, 0x74, 0x65,
0x6E, 0x74, 0x2D, 0x44, 0x69, 0x73, 0x70, 0x6F, 0x73, 0x69,
0x74, 0x69, 0x6F, 0x6E, 0x3A, 0x20, 0x66, 0x6F, 0x72, 0x6D,
0x2D, 0x64, 0x61, 0x74, 0x61, 0x3B, 0x20, 0x6E, 0x61, 0x6D,
0x65, 0x3D, 0x22, 0x46, 0x69, 0x6C, 0x65, 0x6E, 0x61, 0x6D,
0x65, 0x22, 0x0D, 0x0A, 0x0D, 0x0A, 0x61, 0x74, 0x74, 0x2E,
0x74, 0x78, 0x74, 0x0D, 0x0A, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D,
0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x61, 0x65, 0x30,
0x63, 0x48, 0x32, 0x63, 0x48, 0x32, 0x49, 0x6A, 0x35, 0x45,
0x66, 0x31, 0x67, 0x4C, 0x36, 0x4B, 0x4D, 0x37, 0x63, 0x48,
0x32, 0x47, 0x49, 0x33, 0x63, 0x48, 0x32, 0x0D, 0x0A, 0x43,
0x6F, 0x6E, 0x74, 0x65, 0x6E, 0x74, 0x2D, 0x44, 0x69, 0x73,
0x70, 0x6F, 0x73, 0x69, 0x74, 0x69, 0x6F, 0x6E, 0x3A, 0x20,
0x66, 0x6F, 0x72, 0x6D, 0x2D, 0x64, 0x61, 0x74, 0x61, 0x3B,
0x20, 0x6E, 0x61, 0x6D, 0x65, 0x3D, 0x22, 0x46, 0x69, 0x6C,
0x65, 0x64, 0x61, 0x74, 0x61, 0x22, 0x3B, 0x20, 0x66, 0x69,
0x6C, 0x65, 0x6E, 0x61, 0x6D, 0x65, 0x3D, 0x22, 0x61, 0x74,
0x74, 0x2E, 0x74, 0x78, 0x74, 0x22, 0x0D, 0x0A, 0x43, 0x6F,
0x6E, 0x74, 0x65, 0x6E, 0x74, 0x2D, 0x54, 0x79, 0x70, 0x65,
0x3A, 0x20, 0x61, 0x70, 0x70, 0x6C, 0x69, 0x63, 0x61, 0x74,
0x69, 0x6F, 0x6E, 0x2F, 0x6F, 0x63, 0x74, 0x65, 0x74, 0x2D,
0x73, 0x74, 0x72, 0x65, 0x61, 0x6D, 0x0D, 0x0A, 0x0D, 0x0A,
0x6F, 0x6E, 0x65, 0x5F, 0x74, 0x77, 0x6F, 0x5F, 0x74, 0x68,
0x72, 0x65, 0x65, 0x0D, 0x0A, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D,
0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x61, 0x65, 0x30,
0x63, 0x48, 0x32, 0x63, 0x48, 0x32, 0x49, 0x6A, 0x35, 0x45,
0x66, 0x31, 0x67, 0x4C, 0x36, 0x4B, 0x4D, 0x37, 0x63, 0x48,
0x32, 0x47, 0x49, 0x33, 0x63, 0x48, 0x32, 0x0D, 0x0A, 0x43,
0x6F, 0x6E, 0x74, 0x65, 0x6E, 0x74, 0x2D, 0x44, 0x69, 0x73,
0x70, 0x6F, 0x73, 0x69, 0x74, 0x69, 0x6F, 0x6E, 0x3A, 0x20,
0x66, 0x6F, 0x72, 0x6D, 0x2D, 0x64, 0x61, 0x74, 0x61, 0x3B,
0x20, 0x6E, 0x61, 0x6D, 0x65, 0x3D, 0x22, 0x55, 0x70, 0x6C,
0x6F, 0x61, 0x64, 0x22, 0x0D, 0x0A, 0x0D, 0x0A, 0x53, 0x75,
0x62, 0x6D, 0x69, 0x74, 0x20, 0x51, 0x75, 0x65, 0x72, 0x79,
0x0D, 0x0A, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D,
0x2D, 0x2D, 0x2D, 0x2D, 0x61, 0x65, 0x30, 0x63, 0x48, 0x32,
0x63, 0x48, 0x32, 0x49, 0x6A, 0x35, 0x45, 0x66, 0x31, 0x67,
0x4C, 0x36, 0x4B, 0x4D, 0x37, 0x63, 0x48, 0x32, 0x47, 0x49,
0x33, 0x63, 0x48, 0x32, 0x2D, 0x2D
};
1 楼 a_10jqka_2010 2012-04-21  
程序主动构建 http 的命令,我的一片代码,其中涉及有关 cookie 的操作。不知是否好懂,请阅!

相关推荐

    对于C#(HttpClient)方式网络请求的封装

    1. **HttpClient的基本使用**:介绍HttpClient类的基本概念,包括如何创建实例,设置请求头,以及发送GET和POST请求。 2. **封装的设计**:讨论如何设计一个网络请求的通用接口或类,比如定义方法如`SendGetAsync`...

    httpclient请求方式+cookies

    httpclient 请求两种方式,如果有cookie可加上cookies,同步获取返回值

    httpclient

    HttpClient支持多种HTTP方法,如GET、POST、PUT、DELETE等,可以方便地进行HTTP头的设置,发送cookies,处理重定向,甚至实现HTTP/1.1和HTTP/2之间的平滑切换。此外,HttpClient还提供了对HTTPS的支持,确保数据传输...

    apache httpclient jar包

    - HttpClient内置了CookieSpec和CookieStore,用于处理服务器返回的cookies和发送cookies到服务器。 8. **异步请求**: - HttpClient也支持异步请求,使用FutureCallback接口可以注册回调函数处理请求完成后的...

    httpclient4.1.2.zip

    此外,HttpClient 4.1.2还提供了对cookies的处理,通过`CookieStore`和`CookieSpec`接口,可以实现cookies的存储、读取和管理,从而保持会话状态。 在错误处理上,HttpClient 4.1.2引入了重试策略,当网络不稳定...

    httpclient4.5.3 jar完整包含所有依赖包

    完全兼容jdk1.7,1.8,完整包含所有依赖包...* [HTTPCLIENT-1788] RFC 6265 policy must not reject cookies with paths that are no prefix of the uri path. Contributed by Oleg Kalnichevski &lt;olegk at apache.org&gt;

    HttpClient-4.3.6

    2. **examples** 目录:这个目录提供了使用HttpClient的示例代码,涵盖了各种常见的HTTP操作,如GET、POST、PUT、DELETE等方法,以及处理重定向、认证、cookies、多线程等场景。通过这些示例,开发者可以快速理解...

    org.apache.commons.httpclient

    这些示例可能包括发起GET和POST请求,设置请求头,处理cookies,管理连接池,以及处理重定向和错误响应。这些例子对于初学者来说是极好的学习资源,可以帮助他们快速理解和掌握HttpClient的用法。 HttpClient的架包...

    HttpClient3.1.jar

    这个库被广泛用于开发需要与Web服务器交互的应用程序,比如发送HTTP请求、接收响应、处理Cookies、管理会话等。以下是对HttpClient3.1及其相关组件的详细解释: 1. **HttpClient**:HttpClient是Apache软件基金会的...

    org.apache.commons.httpclient相关架包

    5. **Cookie管理**:HttpClient可以自动处理服务器返回的cookies,保持会话状态,方便处理登录和其他需要保持状态的场景。 6. **异步请求**:虽然HttpClient主要是同步操作,但通过配合线程或者回调机制,可以实现...

    java httpclient 模拟登录

    在"java httpclient 模拟登录"这个场景下,我们通常会用到HttpClient来模拟用户登录网站的过程,获取登录后的session信息,以便后续能够访问登录后才能看到的页面内容。以下将详细介绍如何使用Java HttpClient进行...

    HttpClient模拟登录实例

    HttpClient提供了`CookieStore`接口,可以用来存储和管理cookies。 总之,HttpClient提供了一套强大的API,使Java开发者能够轻松地模拟浏览器进行HTTP通信,包括模拟登录操作。通过理解其核心概念和方法,我们可以...

    org.apache.commons.httpclient相关资源包

    Apache HttpClient库是Apache软件基金会的一个项目,它提供了对HTTP协议的全面支持,包括GET、POST、PUT等HTTP方法,以及处理cookies、重定向、身份验证等功能。 描述中提到的三个JAR文件分别是: 1. **commons-...

    HttpClient jar包下载

    9. **Cookie管理**:HttpClient有一个CookieStore接口,用于存储和管理cookies。这在需要保持会话状态或处理服务器的Set-Cookie响应头时很有用。 10. **错误处理**:在处理响应时,需要检查状态码以确定请求是否...

    httpClient入门

    4. `commons-codec-1.4.jar`:提供了各种编码算法,如Base64和Hex,HttpClient可能用它来编码URL、处理cookies或其他需要编码的数据。 在使用HttpClient时,开发者需要注意一些最佳实践,例如正确关闭连接,处理...

    httpclient如何保持session会话模拟登录后的操作

    本文将详细讲解如何使用HTTPClient来保持session会话,从而实现模拟登录后的其他操作。 首先,理解session的概念至关重要。Session是服务器端用来跟踪用户状态的一种机制。在Web应用中,当用户登录后,服务器会为该...

    org.apache.commons.httpclient-3.1.jar

    4. **管理Cookies**:维持会话状态,实现登录保持功能。 5. **使用代理**:在需要经过代理服务器访问互联网的环境中工作。 6. **进行认证**:对受保护的Web资源进行身份验证。 总的来说,Apache Commons HttpClient...

Global site tag (gtag.js) - Google Analytics