Post by a***@gmail.comPost by Alexander NickolovTom pretty much gave you the blow by blow account.
I just wanted to clarify that you don't drop incoming data,
only the outgoing request. E.g. you drop in WSPSend, not
in WSPRecv.
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
MVP VC FAQ:http://vcfaq.mvps.org
=====================================
Post by a***@gmail.comPost by Alexander NickolovThis is a response, so naturally you _don't_ send it - you
_return_ it. E.g. in your WSPRecv implementation. Wait
until the entire request has been sent (might be a few sends
on the client part) and be sure to drop all the data, then
mark the socket as readable and return your own response
from WSPRecv. If you want to close the socket, be sure
to pass the Connection: close header in the response and
then close the socket after you deliver the entire response.
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
MVP VC FAQ:http://vcfaq.mvps.org
=====================================
Post by a***@gmail.comPost by Alexander NickolovIdeally you should be returning a 403 Forbidden HTTP reponse
instead of closing the socket. This will let the browser properly
display a page with the Forbidden message. You can return an
HTML page with 403 and the browser will display it.
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
MVP VC FAQ:http://vcfaq.mvps.org
=====================================
Post by a***@gmail.comHi,
I am trying to do outbound URL filtering using LSP, basically I
check outbound HTTP request from WSPSend and if I find the URL that
needs to be blocked, then I call WSPCloseSocket and return the error
code from that call, that works fine with Firefox, but for IE, it
will display "Internet Explorer cannot display the webpage". Is it
possible not showing this page after blocking and still shows the
previous page?
Anything I should change in the code, such as return different error
code, set
lpErrno parameter to specific Winsock error code? TIA.- Hide quoted
text -
- Show quoted text -
Thx. How do I send HTTP 403 response? through the socket from WSPSend
or create a new socket? Also where should I send the response, I tried
sending HTTP 403 response by calling WSPSend with the socket provided
by previous WSPSend, it doesn't work. Any advise will be greatly
appreciated.- Hide quoted text -
- Show quoted text -
I am confused. So You are suggesting I drop the response from the
blocked web site in the WSPRecv and sends HTTP 403 to client. But how
do I know which WSPRecv needs to be dropped? Is it possible to send
HTTP 403 in the WSPSend because in it I can know for sure if the URL
needs to be blocked? What is the exact flow? TIA.- Hide quoted text -
- Show quoted text -
Thx, guys. I guess what i should do is add a flag sush as "Blocked" in
the SOCKET_CONTEXT, and set this flag in the WSPSend when the HTTP
request should be blocked. And in the WSPRecv, if the flag is set,
fill the buffer with HTTP 403 and close the connection. Pls correct if
this is not right.- Hide quoted text -
- Show quoted text -
OK, guys. I put in following code:
1) in the SOCKET_CONTEXT, I added a field "Block" which is BOOL.
2) in the WSPSend, I have something like following:
......
if (URL needs to be blocked)
{
sockContext->Block = TRUE;
*lpErrno = 0;
return NO_ERROR;
}
..... // do as before
3) In the WSPRecv. I have something like following:
......
if (sockContext->Block)
{
FiillBuffer(lpBuffers, lpNumberOfBytesRecvd ); // fill buffer with
HTTP 403, and set number of bytes received
*lpErrno = 0;
return NO_ERROR;
}
..... // do as before
But I noticed that in the WSPRecv, the code never finds the socket
context with "Block" field set to true because the SOCKET handles
passed into WSPSend and WSPRecv are never same. What is wrong with the
code? Any advice is greatly appeciated.