Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'https': 0.07; 'override': 0.07; 'urllib2': 0.07; 'advance.': 0.09; '>>>>': 0.09; 'command- line': 0.09; 'subject:DNS': 0.09; 'pm,': 0.10; 'binary': 0.14; 'wrote:': 0.14; 'curl': 0.16; 'f.read()': 0.16; 'url:html)': 0.16; 'cc:addr:python-list': 0.17; 'tue,': 0.17; 'header:In-Reply-To:1': 0.21; 'cc:2**0': 0.22; 'cc:no real name:2**0': 0.23; 'trying': 0.23; 'subject:Question': 0.25; 'url:mailman': 0.26; 'script': 0.27; 'sender:addr:gmail.com': 0.28; 'message-id:@mail.gmail.com': 0.28; 'thanks': 0.28; 'problem': 0.28; 'host': 0.29; 'version': 0.29; 'cc:addr:python.org': 0.30; 'url:listinfo': 0.30; 'received:209.85.215': 0.30; 'print': 0.31; 'michael': 0.32; 'apply': 0.32; 'question': 0.34; 'option': 0.35; 'dns': 0.35; 'option.': 0.35; 'yet,': 0.35; 'else': 0.35; 'received:google.com': 0.37; 'something': 0.37; 'received:209.85': 0.37; 'http': 0.37; 'case': 0.37; 'url:python': 0.38; 'could': 0.38; 'url:org': 0.38; 'but': 0.38; 'returning': 0.38; 'subject:: ': 0.38; 'some': 0.38; 'url:google': 0.38; 'received:209': 0.39; 'add': 0.39; 'feature': 0.40; 'header': 0.40; 'introduced': 0.40; 'plain': 0.40; 'hope': 0.60; 'domains': 0.67; 'url:c': 0.72; 'can\x92t': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=ys+BFnJoutXKW3xyA3QRs0xDAMPSRJtBGsgvgbeqiNM=; b=OOGBq4QYwiG6NcL1mQmBgJfrS1uKGDu3S53XweNcujj6QJf3xiGZXwhhmeLSHwUS0v ZlG+KCIVleMzs25vubj3a+ZKGU7XCZz0b7+vzZ4YBe+nzlxOzVKwGUb9srMGx/gPzrDz Lra3f3jpLR/IUcWPUVcBAeqtjogoMnAvM7H+s= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=LZmgZKMv1Q7rJ7E5OBiWYN6ielvVQNhjPzerhcG/L0zkj8gL2Jhh+9iEcoqr9hQX+M IISZVW8D+4APB9ck7A1vmJnnWH/TyVXyqRDWk01LRdnin1BCFcw5HmFoYmxseqRV07BF w2Gld2/nz7bxp86nYjOwcGRWxDbUoYL1XydpY= MIME-Version: 1.0 Sender: mhrivnak@gmail.com In-Reply-To: References: Date: Sat, 18 Jun 2011 14:03:10 -0400 X-Google-Sender-Auth: PYchDTisokGOA9H7qoBZLYEU59k Subject: Re: Question regarding DNS resolution in urllib2 From: Michael Hrivnak To: saurabh verma Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 35 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1308420197 news.xs4all.nl 49178 [::ffff:82.94.164.166]:37994 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:7918 The latest libcurl includes the CURLOPTS_RESOLVE option (http://curl.haxx.se/libcurl/c/curl_easy_setopt.html) that will do what you want. It may not have made its way into pycurl yet, but you could just call the command-line curl binary with the --resolve option. This feature was introduced in version 7.21.3. Michael On Tue, Jun 14, 2011 at 2:34 PM, saurabh verma wro= te: > hi , > > I trying to use urllib2 in my script , but the problem is lets say a doma= ins resolves to multiple IPs , If the URL is served by plain http , I can a= dd =93Host: domain=94 header and check whether all IPs are returning proper= responses or not , but in case of https , I have to trust on my local mach= ines dns resolver and I can=92t apply host header in the request . > > Is it possible to override dns resolver in urllib2 or something else ? > >>>> req =3D urllib2.Request(url=3D'https://google.com/') >>>> f =3D urllib2.urlopen(req) >>>> print f.read() > > I wanted to control the IPs which urllib2 is trying to connect . > > > I Hope I am some sense out of my question , > > Thanks in advance. > > ~saurabh > -- > http://mail.python.org/mailman/listinfo/python-list >