Discussion:
URL filtering using LSP
(too old to reply)
a***@gmail.com
2007-09-27 19:27:16 UTC
Permalink
Hi,

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.
Alexander Nickolov
2007-09-27 23:03:30 UTC
Permalink
Ideally 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
email: ***@mvps.org
MVP VC FAQ: http://vcfaq.mvps.org
=====================================
Post by a***@gmail.com
Hi,
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.
a***@gmail.com
2007-09-28 15:52:41 UTC
Permalink
Post by Alexander Nickolov
Ideally 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.com
Hi,
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.
Alexander Nickolov
2007-09-28 17:01:03 UTC
Permalink
This 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
email: ***@mvps.org
MVP VC FAQ: http://vcfaq.mvps.org
=====================================
Post by a***@gmail.com
Post by Alexander Nickolov
Ideally 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.com
Hi,
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.
a***@gmail.com
2007-09-28 19:18:10 UTC
Permalink
Post by Alexander Nickolov
This 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.com
Post by Alexander Nickolov
Ideally 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.com
Hi,
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.
Tom Handal
2007-09-30 05:29:26 UTC
Permalink
Post by a***@gmail.com
Post by Alexander Nickolov
This 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.com
Post by Alexander Nickolov
Ideally 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.com
Hi,
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.
Hi Andy,

What Alexander is saying is this:

1. Inside of WSPSend, check for the HTTP request to the URL that you
want to block.
2. When the URL is detected, you want to not pass the send down to the
next layer, but return a success status code.
3. Because you returned the success status code, the browser will call
a WSPRecv.
4. Inside of the WSPRecv, you have to have a flag saying that the last
call was blocked, so in this WSPRecv, don't call down
to the next layer, but just fill their buffer with a HTTP 403 that
you make up. Return that back to the caller.
5. This 403 will show up in the browser instead of a error (due to
closed connection).
6. Close connection...

Hope this helps..

Tom Handal
comodus77
2011-09-14 13:16:17 UTC
Permalink
Tom Handal wrote on 09/30/2007 01:29 ET
On Sep 28, 12:18 pm, "
On Sep 28, 12:01 pm, "Alexander Nickolov
Post by Alexander Nickolov
This is a response, so naturally you _don't_ send it - yo
_return_ it. E.g. in your WSPRecv implementation. Wai
until the entire request has been sent (might be a few send
on the client part) and be sure to drop all the data, the
mark the socket as readable and return your own respons
from WSPRecv. If you want to close the socket, be sur
to pass the Connection: close header in the response an
then close the socket after you deliver the entire response
Post by Alexander Nickolov
Alexander Nickolo
Microsoft MVP [VC], MCS
email
MVP VC FAQ:http://vcfaq.mvps.or
wrote in messag
news
On Sep 27, 6:03 pm, "Alexander Nickolov
Post by Alexander Nickolov
Ideally you should be returning a 403 Forbidden HTTP repons
instead of closing the socket. This will let the browse
properl
Post by Alexander Nickolov
Post by Alexander Nickolov
display a page with the Forbidden message. You can return a
HTML page with 403 and the browser will display it
Post by a***@gmail.com
Post by Alexander Nickolov
Alexander Nickolo
Microsoft MVP [VC], MCS
email
MVP VC FAQ:http://vcfaq.mvps.or
wrote in messag
news
Post by a***@gmail.com
Hi
I am trying to do outbound URL filtering using LSP
basically
Post by Alexander Nickolov
Post by Alexander Nickolov
Post by a***@gmail.com
check outbound HTTP request from WSPSend and if I find th
URL tha
Post by Alexander Nickolov
Post by Alexander Nickolov
Post by a***@gmail.com
needs to be blocked, then I call WSPCloseSocket and retur
the erro
Post by Alexander Nickolov
Post by Alexander Nickolov
Post by a***@gmail.com
code from that call, that works fine with Firefox, but fo
IE, i
Post by Alexander Nickolov
Post by Alexander Nickolov
Post by a***@gmail.com
will display "Internet Explorer cannot display th
webpage". Is i
Post by Alexander Nickolov
Post by Alexander Nickolov
Post by a***@gmail.com
possible not showing this page after blocking and stil
shows th
Post by Alexander Nickolov
Post by Alexander Nickolov
Post by a***@gmail.com
previous page
Anything I should change in the code, such as retur
different erro
Post by Alexander Nickolov
Post by Alexander Nickolov
Post by a***@gmail.com
code, se
lpErrno parameter to specific Winsock error code? TIA.
Hide quote
Post by Alexander Nickolov
Post by Alexander Nickolov
Post by a***@gmail.com
text
- Show quoted text
Thx. How do I send HTTP 403 response? through the socket fro
WSPSen
Post by Alexander Nickolov
or create a new socket? Also where should I send the response,
trie
Post by Alexander Nickolov
sending HTTP 403 response by calling WSPSend with the socke
provide
Post by Alexander Nickolov
by previous WSPSend, it doesn't work. Any advise will be greatl
appreciated.- Hide quoted text
- Show quoted text
I am confused. So You are suggesting I drop the response from th
blocked web site in the WSPRecv and sends HTTP 403 to client. But ho
do I know which WSPRecv needs to be dropped? Is it possible to sen
HTTP 403 in the WSPSend because in it I can know for sure if the UR
needs to be blocked? What is the exact flow? TIA
Hi Andy
What Alexander is saying is this
1. Inside of WSPSend, check for the HTTP request to the URL that yo
want to block
2. When the URL is detected, you want to not pass the send down to th
next layer, but return a success status code
3. Because you returned the success status code, the browser will cal
a WSPRecv
4. Inside of the WSPRecv, you have to have a flag saying that the las
call was blocked, so in this WSPRecv, don't call dow
to the next layer, but just fill their buffer with a HTTP 403 tha
you make up. Return that back to the caller
5. This 403 will show up in the browser instead of a error (due t
closed connection)
6. Close connection..
Hope this helps.
Tom Handa
H
Why you not block your URL in WSPConnect function?

Tom Handal
2007-09-30 05:29:50 UTC
Permalink
Post by a***@gmail.com
Post by Alexander Nickolov
This 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.com
Post by Alexander Nickolov
Ideally 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.com
Hi,
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.
Hi Andy,

What Alexander is saying is this:

1. Inside of WSPSend, check for the HTTP request to the URL that you
want to block.
2. When the URL is detected, you want to not pass the send down to the
next layer, but return a success status code.
3. Because you returned the success status code, the browser will call
a WSPRecv.
4. Inside of the WSPRecv, you have to have a flag saying that the last
call was blocked, so in this WSPRecv, don't call down
to the next layer, but just fill their buffer with a HTTP 403 that
you make up. Return that back to the caller.
5. This 403 will show up in the browser instead of a error (due to
closed connection).
6. Close connection...

Hope this helps..

Tom Handal
Alexander Nickolov
2007-09-30 20:28:05 UTC
Permalink
Tom 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
email: ***@mvps.org
MVP VC FAQ: http://vcfaq.mvps.org
=====================================
Post by a***@gmail.com
Post by Alexander Nickolov
This 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.com
Post by Alexander Nickolov
Ideally 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.com
Hi,
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.
a***@gmail.com
2007-09-30 22:06:20 UTC
Permalink
Post by Alexander Nickolov
Tom 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.com
Post by Alexander Nickolov
This 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.com
Post by Alexander Nickolov
Ideally 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.com
Hi,
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.
a***@gmail.com
2007-10-01 15:18:44 UTC
Permalink
Post by a***@gmail.com
Post by Alexander Nickolov
Tom 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.com
Post by Alexander Nickolov
This 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.com
Post by Alexander Nickolov
Ideally 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.com
Hi,
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.
a***@gmail.com
2007-10-01 17:55:07 UTC
Permalink
Post by a***@gmail.com
Post by a***@gmail.com
Post by Alexander Nickolov
Tom 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.com
Post by Alexander Nickolov
This 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.com
Post by Alexander Nickolov
Ideally 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.com
Hi,
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 -
1) in the SOCKET_CONTEXT, I added a field "Block" which is BOOL.
......
if (URL needs to be blocked)
{
sockContext->Block = TRUE;
*lpErrno = 0;
return NO_ERROR;}
..... // do as before
......
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.- Hide quoted text -
- Show quoted text -
I found the reason, I have to set "lpNumberOfBytesSent" in the WSPSend
or WSPRecv won't be called for that socket. One more question though,
to close connection in the WSPRecv, should I call "closesocket" or
"WSPCloseSocket"? TIA.
Loading...