Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
urllib.request.Request Class Reference

List of all members.

Public Member Functions

def __init__
def get_method
def add_data
def has_data
def get_data
def get_full_url
def get_type
def get_host
def get_selector
def is_unverifiable
def get_origin_req_host
def set_proxy
def has_proxy
def add_header
def add_unredirected_header
def has_header
def get_header
def header_items

Public Attributes

 full_url
 fragment
 data
 headers
 unredirected_hdrs
 origin_req_host
 unverifiable
 selector
 host
 type

Private Member Functions

def _parse

Private Attributes

 _tunnel_host

Detailed Description

Definition at line 177 of file request.py.


Constructor & Destructor Documentation

def urllib.request.Request.__init__ (   self,
  url,
  data = None,
  headers = {},
  origin_req_host = None,
  unverifiable = False 
)

Definition at line 180 of file request.py.

00180 
00181                  origin_req_host=None, unverifiable=False):
00182         # unwrap('<URL:type://host/path>') --> 'type://host/path'
00183         self.full_url = unwrap(url)
00184         self.full_url, self.fragment = splittag(self.full_url)
00185         self.data = data
00186         self.headers = {}
00187         self._tunnel_host = None
00188         for key, value in headers.items():
00189             self.add_header(key, value)
00190         self.unredirected_hdrs = {}
00191         if origin_req_host is None:
00192             origin_req_host = request_host(self)
00193         self.origin_req_host = origin_req_host
00194         self.unverifiable = unverifiable
00195         self._parse()

Here is the caller graph for this function:


Member Function Documentation

def urllib.request.Request._parse (   self) [private]

Definition at line 196 of file request.py.

00196 
00197     def _parse(self):
00198         self.type, rest = splittype(self.full_url)
00199         if self.type is None:
00200             raise ValueError("unknown url type: %s" % self.full_url)
00201         self.host, self.selector = splithost(rest)
00202         if self.host:
00203             self.host = unquote(self.host)

Here is the call graph for this function:

def urllib.request.Request.add_data (   self,
  data 
)

Definition at line 212 of file request.py.

00212 
00213     def add_data(self, data):
00214         self.data = data

def urllib.request.Request.add_header (   self,
  key,
  val 
)

Definition at line 255 of file request.py.

00255 
00256     def add_header(self, key, val):
00257         # useful for something like authentication
00258         self.headers[key.capitalize()] = val

def urllib.request.Request.add_unredirected_header (   self,
  key,
  val 
)

Definition at line 259 of file request.py.

00259 
00260     def add_unredirected_header(self, key, val):
00261         # will not be added to a redirected request
00262         self.unredirected_hdrs[key.capitalize()] = val

Definition at line 218 of file request.py.

00218 
00219     def get_data(self):
00220         return self.data

Here is the caller graph for this function:

Definition at line 221 of file request.py.

00221 
00222     def get_full_url(self):
00223         if self.fragment:
00224             return '%s#%s' % (self.full_url, self.fragment)
00225         else:
00226             return self.full_url

def urllib.request.Request.get_header (   self,
  header_name,
  default = None 
)

Definition at line 267 of file request.py.

00267 
00268     def get_header(self, header_name, default=None):
00269         return self.headers.get(
00270             header_name,
00271             self.unredirected_hdrs.get(header_name, default))

Definition at line 230 of file request.py.

00230 
00231     def get_host(self):
00232         return self.host

Definition at line 204 of file request.py.

00204 
00205     def get_method(self):
00206         if self.data is not None:
00207             return "POST"
00208         else:
00209             return "GET"

Definition at line 239 of file request.py.

00239 
00240     def get_origin_req_host(self):
00241         return self.origin_req_host

Definition at line 233 of file request.py.

00233 
00234     def get_selector(self):
00235         return self.selector

Definition at line 227 of file request.py.

00227 
00228     def get_type(self):
00229         return self.type

Definition at line 215 of file request.py.

00215 
00216     def has_data(self):
00217         return self.data is not None

def urllib.request.Request.has_header (   self,
  header_name 
)

Definition at line 263 of file request.py.

00263 
00264     def has_header(self, header_name):
00265         return (header_name in self.headers or
00266                 header_name in self.unredirected_hdrs)

Definition at line 252 of file request.py.

00252 
00253     def has_proxy(self):
00254         return self.selector == self.full_url

Definition at line 272 of file request.py.

00272 
00273     def header_items(self):
00274         hdrs = self.unredirected_hdrs.copy()
00275         hdrs.update(self.headers)
00276         return list(hdrs.items())

Definition at line 236 of file request.py.

00236 
00237     def is_unverifiable(self):
00238         return self.unverifiable

def urllib.request.Request.set_proxy (   self,
  host,
  type 
)

Definition at line 244 of file request.py.

00244 
00245     def set_proxy(self, host, type):
00246         if self.type == 'https' and not self._tunnel_host:
00247             self._tunnel_host = self.host
00248         else:
00249             self.type= type
00250             self.selector = self.full_url
00251         self.host = host


Member Data Documentation

Definition at line 186 of file request.py.

Definition at line 184 of file request.py.

Definition at line 183 of file request.py.

Definition at line 182 of file request.py.

Definition at line 185 of file request.py.

Definition at line 202 of file request.py.

Definition at line 192 of file request.py.

Definition at line 200 of file request.py.

Definition at line 245 of file request.py.

Definition at line 189 of file request.py.

Definition at line 193 of file request.py.


The documentation for this class was generated from the following file: