idHttp 403 Forbidden 에러 원인
델파이에서 idHttp를 이용하여 이미지를 보여줄 때 특정 사이트에서 이미지가 보여지지 않았다
에러를 추적해 보니 403 Forbidden 에러가 발생한다.
델마당에서 검색해 보니 어느 분이 idHttp1.Request.UserAgent 속성의 기본값 "Mozilla/3.0 (compatible; Indy Library)"을
임시로 아무런 문자로 바꾸라고 한다. 그냥 "a" 로 바꾸니 신기하게 잘 작동한다.
그런데 왠지 "a"라고 넣기에는 찝찝했다.
궁금증이 생겼다. UserAgent 속성과 Mozilla/3.0 ... 이 무엇인지 ....
역시 검색은 구글인것 같다. 원하는 답이 나왔다.
이하퍼옴( 하창호닷컴)
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 ")".
고마운 분이다.
대충 해석해 보니 상당수 악성 코드가 UserAgent속성이 "Mozilla/3.0 (compatible; Indy Library)" 으로 되어 있어 특정사이트는
"Mozilla/3.0 (compatible; Indy Library)'으로 들어 접근을 막는 다는 것이다. 그러니 "Mozilla/3.0 (compatible; " followed by the name of your program, followed by a ")" 식으로 프로그램의 출처를 적으면 된다는 것이다. 그러니 "a"만 넣어도 잘 작동한 것이다.
그럼 UserAgent속성이 무엇인지 확인해 보니
모든 웹브라우저는 고유의 UserAgent가 있고 그것으로 접근하는 기기의 브라우저의 종류와 버전, OS 를 알 수 있단다.
요즘 스마트폰이 인기있으니 스마트폰으로 접근했는지 pc로 접근햇는지도 알 수 있을 것 같다.
왜 MS사의 브라우저도 Mozilla/3.0 .... 인지 궁금했는데
또 다시 고마운 분이 있다.
이런 훌륭한 분들 때문에 세상은 아름답다.