Lines Matching +full:basic +full:- +full:ftp
1 .. _urllib-howto:
12 HOWTO, available at `urllib2 - Le Manuel manquant
25 * `Basic Authentication <http://www.voidspace.org.uk/python/articles/authentication.shtml>`_
27 A tutorial on *Basic Authentication*, with examples in Python.
33 handling common situations - like basic authentication, cookies, proxies and so
37 before the ``":"`` in URL - for example ``"ftp"`` is the URL scheme of
38 ``"ftp://python.org/"``) using their associated network protocols (e.g. FTP, HTTP).
42 encounter errors or non-trivial cases when opening HTTP URLs, you will need some
60 could have used a URL starting with 'ftp:', 'file:', etc.). However, it's the
64 HTTP is based on requests and responses - the client makes requests and servers
69 a file-like object, which means you can for example call ``.read()`` on the
79 schemes. For example, you can make an FTP request like so::
81 req = urllib2.Request('ftp://example.com/')
86 the server - this information is sent as HTTP "headers". Let's look at each of
90 ----
105 url = 'http://www.someserver.com/cgi-bin/register.cgi'
116 forms - see `HTML Specification, Form Submission
117 <https://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13>`_ for more
122 "side-effects": they change the state of the system in some way (for example by
125 intended to *always* cause side-effects, and GET requests *never* to cause
126 side-effects, nothing prevents a GET request from having side-effects, nor a
127 POST requests from having no side-effects. Data can also be passed in an HTTP
149 -------
156 ``Python-urllib/x.y`` (where ``x`` and ``y`` are the major and minor version
158 e.g. ``Python-urllib/2.5``), which may confuse the site, or just plain
160 ``User-Agent`` header [#]_. When you create a Request object you can
168 url = 'http://www.someserver.com/cgi-bin/register.cgi'
173 headers = {'User-Agent': user_agent}
188 usual with Python APIs, built-in exceptions such as :exc:`ValueError`,
195 --------
213 ---------
232 codes in the 100--299 range indicate success, you will usually only see error
233 codes in the 400--599 range.
249 'Request accepted, processing continues off-line'),
250 203: ('Non-Authoritative Information', 'Request fulfilled from cache'),
256 'Object has several resources -- see URI list'),
257 301: ('Moved Permanently', 'Object moved permanently -- see URI list'),
258 302: ('Found', 'Object moved temporarily -- see URI list'),
259 303: ('See Other', 'Object moved -- see Method and URL list'),
266 'Object moved temporarily -- see URI list'),
271 'No permission -- see authorization schemes'),
273 'No payment -- see charging schemes'),
275 'Request forbidden -- authorization will not help'),
286 411: ('Length Required', 'Client must specify Content-Length.'),
289 414: ('Request-URI Too Long', 'URI is too long.'),
320 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
321 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
328 --------------
331 basic approaches. I prefer the second approach.
384 **geturl** - this returns the real URL of the page fetched. This is useful
388 **info** - this returns a dictionary-like object that describes the page
392 Typical headers include 'Content-length', 'Content-type', and so on. See the
402 confusingly-named :class:`urllib2.OpenerDirector`). Normally we have been using
403 the default opener - via ``urlopen`` - but you can create custom
406 ftp, etc.), or how to handle an aspect of URL opening, for example HTTP
433 Basic Authentication
437 ``HTTPBasicAuthHandler``. For a more detailed discussion of this subject --
438 including an explanation of how Basic Authentication works - see the `Basic
444 and a 'realm'. The header looks like: ``WWW-Authenticate: SCHEME
449 WWW-Authenticate: Basic realm="cPanel Users"
453 for the realm included as a header in the request. This is 'basic
467 The top-level URL is the first URL that requires authentication. URLs "deeper"
494 -- ``ProxyHandler`` (if a proxy setting such as an :envvar:`http_proxy`
504 NOT contain the "userinfo" component - for example ``"joe:password@example.com"`` is
511 **urllib2** will auto-detect your proxy settings and use those. This is through
516 setting up a `Basic Authentication`_ handler: ::
559 -------
570 .. [#] Browser sniffing is a very bad practice for website design - building