----- Original Message -----
Sent: Wednesday, October 30, 2002 11:17
PM
Subject: SSL_read() hang after read http
100 continue headers
Hi,
My program is using
OpenSSL function SSL_read() to read http content.
It works fine for most of
the headers, but after it receives HTTP/1.1
100 Continue header (the first block of headers), it will hang
there. It should continue to read
the
headers (which is HTTP/1.1 200 OK...). The following is the header
dumping
and the code I used. The http equivalent code works fine. After the first block of headers, it should
continually read the 2nd block of headers.
Is it
because after the first block of header (see the following), the
terminators 0d 0a 0d 0a confused SSL_read? or the terminators are
the same as SSL block terminator? How can I get around it?
This is the first
block of headers
HTTP/1.1
100 Continue
Server:
Microsoft-IIS/5.0
Date:Wed, 30 Oct
2002 06:34:56
GMT
Can
you help me?
Thank
you.
while (Retries <= 4 )
{
len =
strlen(buf);
printf("before
SSL_read(), buf len=%d\n",
len);
r=SSL_read(Connect->ssl,buf,100);
err =
SSL_get_error(Connect->ssl, r);
printf("r=%d, err=%d\n", r,
err);
if (err == SSL_ERROR_NONE)
bytes =
r;
if (err != SSL_ERROR_NONE && err != SSL_ERROR_WANT_READ
&& err ==
SSL_ERROR_ZERO_RETURN)
{
printf("
SSL_ERROR_ZERO_RETURN\n");
break;
}
if (err != SSL_ERROR_NONE
&& err != SSL_ERROR_WANT_READ && err
==
SSL_ERROR_SYSCALL)
{
printf("
SSL_ERROR_SYSCALL\n");
break;
}
if (err != SSL_ERROR_NONE
&& err != SSL_ERROR_WANT_READ && err !=
SSL_ERROR_SYSCALL
&& err != SSL_ERROR_ZERO_RETURN)
{
printf("Reading header, SSL
read problem\n");
break;
}
if (bytes < 0 &&
Control->AGW==1) {
printf("read returned -1 (Error %d), returning
...\n", errno);
break;
}
else if (bytes == 0)
{
Retries++;
}
else if (bytes > 0)
{
buf[bytes] =
'\0';
printf("read %d bytes, buf={%s}\n", bytes, buf);
}
}
0x00000000 | 48 54 54 50 2f 31 2e 31 20 31 30 30 20 43 6f 6e
|HTTP/1.1 100 Con
0x00000010 | 74 69 6e 75 65 0d 0a 53 65 72 76 65 72 3a 20
4d |tinue..Server: M
0x00000020 | 69 63 72 6f 73 6f 66 74 2d 49 49 53 2f 35
2e 30 |icrosoft-IIS/5.0
0x00000030 | 0d 0a 44 61 74 65 3a 20 57 65 64 2c 20
33 30 20 | ..Date:Wed, 30
0x00000040 | 4f 63 74 20 32 30 30 32 20 30 36 3a
33 34 3a 35 | Oct 2002
06:34:5
0x00000050 | 36 20 47 4d 54 0d 0a 0d
0a
| 6 GMT....
0x00000000 | 48 54 54
50 2f 31 2e 31 20 32 30 30 20 4f 4b 0d |HTTP/1.1 200 OK.
0x00000010 | 0a 53
65 72 76 65 72 3a 20 4d 69 63 72 6f 73 6f |.Server: Microso
0x00000020 | 66
74 2d 49 49 53 2f 35 2e 30 0d 0a 44 61 74 65 |ft-IIS/5.0..Date
0x00000030 |
3a 20 57 65 64 2c 20 33 30 20 4f 63 74 20 32 30 | : Wed,30 Oct
20
0x00000040 | 30 32 20 30 36 3a 33 35 3a 30 37 20 47 4d 54 0d | 02 06:35:07 GMT.
0x00000050 | 0a 43 6f 6e 74
65 6e 74 2d 4c 65 6e 67 74 68 3a |.Content-Length:
0x00000060 | 20 31 38 36
33 0d 0a 43 6f 6e 74 65 6e 74 2d 54 |1863..Content-T
0x00000070 | 79 70 65
3a 20 74 65 78 74 2f 68 74 6d 6c 0d 0a | ype:text/html..
0x00000080 | 45 78
70 69 72 65 73 3a 20 57 65 64 2c 20 33 30 |Expires: Wed, 30
0x00000090 | 20
4f 63 74 20 32 30 30 32 20 30 36 3a 33 35 3a | Oct 2002 06:35:
0x000000a0 | 30 37 20 47 4d 54
0d 0a 43 61 63 68 65 2d 63 6f | 07
GMT..Cache-co
0x000000b0 | 6e 74 72 6f 6c 3a 20 70 72 69 76 61 74 65
0d 0a | ntrol:
private..