mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
Added tests for missing host to open_http and open_gopher
This commit is contained in:
parent
e531e4b042
commit
590b289672
1 changed files with 2 additions and 0 deletions
|
@ -132,6 +132,7 @@ class URLopener:
|
||||||
def open_http(self, url):
|
def open_http(self, url):
|
||||||
import httplib
|
import httplib
|
||||||
host, selector = splithost(url)
|
host, selector = splithost(url)
|
||||||
|
if not host: raise IOError, ('http error', 'no host given')
|
||||||
h = httplib.HTTP(host)
|
h = httplib.HTTP(host)
|
||||||
h.putrequest('GET', selector)
|
h.putrequest('GET', selector)
|
||||||
for args in self.addheaders: apply(h.putheader, args)
|
for args in self.addheaders: apply(h.putheader, args)
|
||||||
|
@ -143,6 +144,7 @@ class URLopener:
|
||||||
def open_gopher(self, url):
|
def open_gopher(self, url):
|
||||||
import gopherlib
|
import gopherlib
|
||||||
host, selector = splithost(url)
|
host, selector = splithost(url)
|
||||||
|
if not host: raise IOError, ('gopher error', 'no host given')
|
||||||
type, selector = splitgophertype(selector)
|
type, selector = splitgophertype(selector)
|
||||||
selector, query = splitquery(selector)
|
selector, query = splitquery(selector)
|
||||||
if query: fp = gopherlib.send_query(selector, query, host)
|
if query: fp = gopherlib.send_query(selector, query, host)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue