473,394 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Re: Host: header

En Mon, 14 Apr 2008 01:04:40 -0300, Penny Y. <py*****@arcor.deescribió:
I have a problem with a request url,for example, I have the code below,

import httplib

try:
conn = httplib.HTTPConnection("192.168.1.1")
conn.request("GET", "/")
r1 = conn.getresponse()
if r1.status == 200:
result = 0
except Exception:
result = -1
but the server on 192.168.1.1 accept virtual host request only.
That's to say, I need to specify a "Host:" header in the request.
How to do it? thanks.
Add a `headers` parameter to the request method.
See http://docs.python.org/lib/httpconnection-objects.html
Something like this (untested):

headers = {'Host', 'the.host.name'}
conn = httplib.HTTPConnection("192.168.1.1")
conn.request("GET", "/", headers=headers)

--
Gabriel Genellina

Jun 27 '08 #1
0 904

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Jeff | last post by:
Is there a way to echo back a case sensitive $HTTP_HOST in PHP? For example if I type HostName.domain.com in my browser I want to return it exactly as it appears in the location part of the browser...
1
by: Frogbčrt | last post by:
Config: Win2K, IIS5.0 My solution requires that the host header sent to IIS be analyzed. I have set up a web site that responds to both www.domain.com and domain.com. In DNS, both a WWW and a *...
7
by: mike | last post by:
regards: Does each HTTP Request have "Host:" header? Any positive suggestion is welcome. thank you May goodness be with you all
2
by: Jeff S | last post by:
What are my options if I want to host hundreds of sites on one IIS server (like Internet presence providers do); such that site1.com, site2.com, site3.com... site278.com... are all hosted on the...
5
by: Pietro | last post by:
Hello, I have several sites hosted in iis, they differer by Host Header, ex: www.mysite.com.br, but i want to open all subdomains in that site , ex: www.*.mysite.com.br, is there any sintax to...
7
by: GopherGold | last post by:
I have a site that uses a combination of Web.Sitemap and a SqlSiteMapProvider that I created (thanks to Jeff Proisse @ MSDN). One node of the Web.Sitemap is the same as the root node from the...
0
by: =?Utf-8?B?UmljaGFyZCBDb2xsZXR0ZQ==?= | last post by:
My goal is to connect a WSE 3.0 client to a WCF asp.net hosted service, utilizing MTOM encoding and if at all possible, streamedRequest transfer mode. I am starting with a basic Hello World...
2
by: suchismita.83 | last post by:
Hi, I want to fetch host header of a site url but not getting idea how to do that. Can we do by using HttpRequest.ServerVariables. I have searched in net but not getting the member through which...
7
by: lmeyers | last post by:
I implemented a URL rewriter which worked reasonably well, but now I am creating other sites on the same server (single IP). Because IIS will not accept subdomain wildcards (*.subdomain.com), it...
0
by: teddarr | last post by:
I have a Windows Server 2003. I am trying to run multiple websites on the server. I am using host headers to run the websites on only one ip address. Before anyone says this is an iis issue and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.