403套接字错误 [英] 403 Socket error

查看:100
本文介绍了403套接字错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在代理服务器上工作,并且一直在使用套接字从Web服务器请求数据,但是现在我又收到了禁止403错误,目录列表被拒绝",但是当我在提琴手中测试请求头时它可以返回页面,但可以查看显示的日志.

检测到HTTP Pipelining Client;会话#1的客户端套接字上的多余数据.

不知道我告诉我什么,但是下面显示的是产生403错误的示例代码.

I have been working on a proxy server and have been using sockets to request data from web servers but now i then i get a Forbidden 403 error with ''directory listing denied'' and yet when i test the request headder in fiddler it works in returning the page but looking at the logs it shows.

HTTP Pipelining Client detected; excess data on client socket for session #1.

Not sure what this i telling me but shown below is sample code that produces the 403 error.

string Request = "GET http://www.bmw.co.uk/bmwuk/homepage/ HTTP/1.1\r\n";
            Request += "Host: www.bmw.co.uk\r\n";
            Request += "Referer: www.bmw.co.uk\r\n\r\n";
            IPEndPoint Ep = new IPEndPoint(Dns.GetHostEntry("www.bmw.co.uk").AddressList[0], 80);
            Socket Soc= new Socket(Ep.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
            Soc.Connect(Ep);
            Soc.ReceiveBufferSize = 1024;
            Soc.Send(ASCIIEncoding.ASCII.GetBytes(Request));
            byte[] Buffer = new byte[1024];
            int BytesReply=Soc.Receive(Buffer);
            string strReply=ASCIIEncoding.ASCII.GetString(Buffer);
            Soc.Close();



键入" www.bmw.co.uk/bmwuk/homepage/ [



Typing "www.bmw.co.uk/bmwuk/homepage/[^] in to a browser show the page and not the directory so i would guess the folder uses a default web page.

Some sites are coded to check the Referer string but as you can see i''ve sent it and i also tried tweaking the buffer size so i''m a bit stuck on this one if anyone has the answer.

推荐答案

您是说此错误是间歇性发生还是反复发生?

我不熟悉提琴手"或其日志文件,请解释.

这可能会帮助您的一个事实:

浏览器发送GET请求时,通常不会在请求的URL中包含域名.例如,如果您连接到www.bmw.co.uk,则GET应该显示为

GET/bmwuk/homepage HTTP/1.1

尝试一下,看看是否有帮助.

另外,不要使用尾部的斜杠字符.这可能是导致服务器认为您正在请求目录列表的原因.
Are you saying that this error happens intermittently, or repeatedly?

I''m not familiar with "fiddler," or its log files, please explain.

Here''s one fact which might help you out:

When browsers send a GET request, they usually don''t include the domain name in the URL of the request. For instance, if you''re connected to www.bmw.co.uk, your GET should read

GET /bmwuk/homepage HTTP/1.1

Try that and see if it helps.

Also, leave off the trailing slash character. That might be what''s causing the server to think you''re requesting a directory list.


谢谢Richard Andrew所做的工作.

Fiddler是用作代理服务器的工具,因此您可以检查发送到Web服务器的请求/响应,这会在GET中显示完整地址,并且当您编辑请求并将完整URL保留在请求中时,它可以从所有服务器上的小提琴手,因此是我的错误.

我认为提琴手会调整事实,因为它无法显示来自经常包含
的浏览器的真实请求.
Thank you Richard Andrew that did the job.

Fiddler is a tool that works as a proxy server so that you can inspect the request/responce sent to web servers and this shows the full address in the GET and when you edit a request and leave the full url in the request it works fine from fiddler on all server and hence my mistake.

I think fiddler tweaks the truth because it does not show the real request from the browser that often included

Proxy-Connection: Keep-Alive



而且我猜想它没有显示发送到服务器的真实请求,这在您考虑时是不好的.

在IIS/6等大多数服务器上都可以使用GET中的完整URL,但在其他服务器上却不能,因此我怀疑它与套接字设置有关,因此感谢您的帮助.



and i would guess it''s not showing the real request sent to the server which is bad when you think about it.

using the full url in the GET works on most servers like IIS/6 but not on others so i suspected it had something to do with socket setting so thanks for your help.


这篇关于403套接字错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆