Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I determine if a HTTP request came from a browser or something else like a web service?

How do I determine if a HTTP request came from a browser or something else like a web service?

I am aware that there is a User Agent, but this seems mainly for web browsers. For instance I do I know the request came from a google maps or youtube. The request are coming off a tethered device.

If they have a different User Agent, can I get an example.

Thanks.

like image 238
Michael Wildermuth Avatar asked Apr 05 '12 19:04

Michael Wildermuth


People also ask

How can you tell when a webpage is requested from a browser?

Browser Sends Request After a browser has performed the DNS lookup, it sends an HTTP request to the appropriate server. It doesn't have to literally be HTTP. It can be HTTPS or more recently an HTTP/2 request. The general idea though it that your browser sends a request for a specific file, often an HTML file.

How do you detect if a HTTP request is coming from a human or a bot?

How do you detect if a HTTP request is coming from a human or a bot? Detect that several unrelated pages were requested directly by some IP (not good enough) Watch for missing headers.It is likely to be a robot if: it requests the HTML page but no images. first requests a robots.

How do you check if a request if coming from the same server or different server?

Basically : you cannot. With the HTTP protocol, each request is independent from the others. A first idea would be to check the Referer HTTP header, but note that : It can be faked (it's sent by the browser)

What type of HTTP request is usually used to access a website?

GET is used to retrieve and request data from a specified resource in a server. GET is one of the most popular HTTP request techniques. In simple words, the GET method is used to retrieve whatever information is identified by the Request-URL.


1 Answers

There is absolutely no way to know with certainty if a request came from a browser or something else making an HTTP request.

The HTTP protocol allows for the client to set the User Agent arbitrarily.

One can attempt to determine if the thing on the other end is a browser e.g. by executing JavaScript and measuring the outcome. However, some bots can execute JavaScript, and not all browsers execute JavaScript so that type of test can never be perfect.

Well-behaved "bots" (like common search engine spiders) will identify themselves using a User Agent specific to them. There's a pretty comprehensive list of user agents here:

http://www.user-agents.org/

http://www.botsvsbrowsers.com/

like image 157
Eric J. Avatar answered Sep 23 '22 21:09

Eric J.