Strange error occured while accessing FDTY

时间:2021-01-05 00:25:01

When I was trying to acess fdty with urllib2, I received a exception which is "HTTP Error 500: Internal Server Error".

the request was:

request = urllib2.Request(
        url     = "
http://www.fdty.fudan.edu.cn/
",
        headers = {'Connection':'close','Accept-Encoding': 'identity', 'User-Agent': 'Python-urllib/2.5'},
        )

and I invoked urllib2.build_opener().open(request).

the error occured. 

 

Whatsmore, I tried in another way which was connecting with httplib.

I sent basic packets by:

conn = httplib.HTTPConnection('www.fdty.fudan.edu.cn')

conn.request('GET', '/tycj/default.asp',None,{'Connection':'close','Accept-Encoding': 'identity', 'User-Agent': 'Python-urllib/2.5'})
res = conn.getresponse()

and then I got the page.

 

I tried to invade pythonw and caught the packets. To my suprise, I found the two program segments indeed sent the same packets and received the same error message as well. But in the first program, an exception was thrown and the process was terminated; in the latter one, the error message was ignored! After the error message, the server responded with the html I required!

PS: I tried to access the site with C#, While I was using WebRequest or such SocketAPIs, I received the same error message. But when I visit it with WebBrowser, the error message no longer appeared...