Модератор: tyomitch
Private Function GetText(ByVal h As XMLHTTPRequest) As String
' Вот зараза!
Dim obptr As Long, stptr As Long, cbstr As Long
CopyMemory obptr, ByVal ObjPtr(h) + &H18, 4
CopyMemory stptr, ByVal obptr + &HA4, 4
CopyMemory cbstr, ByVal obptr + &HAC, 4
GetText = Space(cbstr)
CopyMemory ByVal GetText, ByVal stptr, cbstr
End Function
//
// single 100 response
//
#define TEST_HEADER_0 "HTTP/1.1 100 Continue\r\n" \
"\r\n"
//
// single 100 header
//
#define TEST_HEADER_1 "HTTP/1.1 100 Continue\r\n" \
"Server: Richard's Test-Case Virtual Server/1.0\r\n" \
"Date: Mon, 01 Apr 2000 00:00:01 GMT\r\n" \
"\r\n"
//
// continue header with moderate amount of data
//
#define TEST_HEADER_2 "HTTP/1.1 100 Continue\r\n" \
"Server: Richard's Test-Case Virtual Server/1.0\r\n" \
"Date: Mon, 01 Apr 2000 00:00:01 GMT\r\n" \
"Content-Length: 128\r\n" \
"Content-Type: octet/shmoctet\r\n" \
"\r\n" \
"0123456789abcdef" \
"0123456789abcdef" \
"0123456789abcdef" \
"0123456789abcdef" \
"0123456789abcdef" \
"0123456789abcdef" \
"0123456789abcdef" \
"0123456789abcdef"
//
// continue header seen from apache server
//
#define TEST_HEADER_3 "HTTP/1.1 100 Continue\r\n" \
"\r\n" \
"\n\n\n\n\n"
//
// multiple continue headers, no data
//
#define TEST_HEADER_4 "HTTP/1.1 100 Continue\r\n" \
"Server: Richard's Test-Case Virtual Server/1.0\r\n" \
"Date: Mon, 01 Apr 2000 00:00:01 GMT\r\n" \
"\r\n" \
"HTTP/1.1 100 Continue\r\n" \
"Server: Richard's Test-Case Virtual Server/1.0\r\n" \
"Date: Mon, 01 Apr 2000 00:00:01 GMT\r\n" \
"\r\n" \
"HTTP/1.1 100 Continue\r\n" \
"Server: Richard's Test-Case Virtual Server/1.0\r\n" \
"Date: Mon, 01 Apr 2000 00:00:01 GMT\r\n" \
"\r\n" \
"HTTP/1.1 100 Continue\r\n" \
"Server: Richard's Test-Case Virtual Server/1.0\r\n" \
"Date: Mon, 01 Apr 2000 00:00:01 GMT\r\n" \
"\r\n"
//
// single 100 response, preceeded by preamble and containing a chunked response
//
#define TEST_HEADER_5 "!!!! this is a pre-amble, should be ignored even though it includes HTTP !!!!" \
" " \
"HTTP/1.1 100 Go ahead punk, make my day\r\n" \
"Server: Richard's Test-Case Virtual Server/1.0\r\n" \
"Date: Mon, 01 Apr 2000 00:00:01 GMT\r\n" \
"Transfer-Encoding: chunked\r\n" \
"\r\n" \
"0010 this is the first chunk (16 bytes)\r\n" \
"0123456789abcdef" \
"\r\n" \
" 10; this is the second chunk (16 bytes)\r\n" \
"0123456789abcdef" \
"\r\n" \
"00F3\r\n" \
"0123456789abcdef" \
"0123456789abcdef" \
"0123456789abcdef" \
"0123456789abcdef" \
"0123456789abcdef" \
"0123456789abcdef" \
"0123456789abcdef" \
"0123456789abcdef" \
"0123456789abcdef" \
"0123456789abcdef" \
"0123456789abcdef" \
"0123456789abcdef" \
"0123456789abcdef" \
"0123456789abcdef" \
"0123456789abcdef" \
"012" \
"\r\n" \
"0000; the final chunk\r\n" \
"\r\n" \
"Entity-Header: this is the chunk footer\r\n" \
"\r\n"
//
// enpty chunk encoded response with empty footer
//
#define TEST_HEADER_6 "HTTP/1.1 100 Continue\r\n" \
"Server: Richard's Test-Case Virtual Server/1.0\r\n" \
"Date: Mon, 01 Apr 2000 00:00:01 GMT\r\n" \
"Transfer-Encoding: chunked\r\n" \
"\r\n" \
"0\r\n" \
"\r\n" \
"\r\n"
Dim XmlHttp As Object
Set XmlHttp = CreateObject("Microsoft.XmlHttp")
XmlHttp.open "POST", "http://www.ya.ru", False
XmlHttp.send
Dim ResponseBody() As Byte
ResponseBody = XmlHttp.ResponseBody
Const vbUnicode = 64
Print StrConv(ResponseBody, vbUnicode)
ALX_2002 писал(а):2) А разве нельзя получать данные кусками, поставив в 206 статус ?
Извиняйте, если глупость спросил
Range: 123-456
Range: 123-
А разве нельзя получать данные кусками, поставив в 206 статус ?
ALX_2002 писал(а):1) Такой код не даёт мне гарантии, что я получу русский текст ?
2 tyomitch + Хакер
alibek писал(а):Хакер писал(а):2*tyomitch + Хакер.
= 11505
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 0