How to force web server IP for an HTTP request (python example)

The easiest way to specify an http server IP address, when you want to FORCE a request to a specific server, is to make the http request to that IP, then just include the Host header.

This is not immediately obvious if you do not have some knowledge of the http protocol.

Here is how you do it with the requests library in python:

import requests
url = ‘http://IP_GOES_HERE/’
headers = {‘Host’:’www.EXAMPLE.net’}
r = requests.get(url,headers=headers)

In the above example, the http request will go to server IP_GOES_HERE, and ask for the www.EXAMPLE.net website, using GET.

Basicly, is the same as http://www.example.net …. if the A record in the DNS was IP_GOES_HERE

Artículos relacionados:

Si te gustó este articulo, ¿ Porque no dejas un comentario a continuación y continuas la conversación, o te suscribes a los feeds y recibes los artículos directamente en tu lector?

Comentarios

No comments yet.

Sorry, the comment form is closed at this time.