2014년 12월 21일 일요일

using the HTTP User-Agent

I am getting a 403 Forbidden error with some sites while they work fine with Opera, Netscape Communicator, or Internet Explorer. How do I fix this? 
Previous  Top  Next  

This happening because some administrators are now filtering HTTP requests from programs that send the HTTP User-Agent header with the value "Mozilla/3.0 (compatible; Indy Library)". This is the default value provided by TIdHTTP. Unfortunately, some people used TIdHTTP in their malware (denial of service programs, E-Mail address web-harvesters, password cracking programs. and ill-behaved web-robots). To counter this, some administrators block such programs from accessing their website using the HTTP User-Agent header value meaning that not only will they block those malware programs but other Indy based applications which send the default value. 

We can not change this default value because we provided it for a historical reason. At one time, Netscape Navigator was extremely popular and had some high-end features such as Java, Java Script, and frames as a well as a few proprietary HTML tags. Some webmasters started filtering HTTP requests from non-Netscape web-browsers because they couldn't work on their websites. To bypass this restriction, Microsoft Internet Explorer would send "Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)" and other programs started sending similar strings. When doing Indy 8.0, we were well aware of this and created a default user agent value of "Mozilla/3.0 (compatible; Indy Library)". 

You need to change the TIdHTTP.Request.UserAgent property from the default value to your own value. When doing this, the string should start with the text "Mozilla/3.0 (compatible; " followed by the name of your program, followed by a ")".

🚀 시니어 직장인의 AI 탐구기: OpenCode 완벽 실전 가이드 "코딩을 몰라도 괜찮습니다. 내 컴퓨터 옆자리에 든든한 AI 신입사원을 두고 퇴근 시간을 앞당겨 보세요!" 본 블로그는 시니어 직장인의 현실적...