• Home
  • Raw
  • Download

Lines Matching +full:basic +full:- +full:ftp

1 .. _urllib-howto:
18 …* `Basic Authentication <https://web.archive.org/web/20201215133350/http://www.voidspace.org.uk/py…
20 A tutorial on *Basic Authentication*, with examples in Python.
26 handling common situations - like basic authentication, cookies, proxies and so
30 before the ``":"`` in URL - for example ``"ftp"`` is the URL scheme of
31 ``"ftp://python.org/"``) using their associated network protocols (e.g. FTP, HTTP).
35 encounter errors or non-trivial cases when opening HTTP URLs, you will need some
68 could have used a URL starting with 'ftp:', 'file:', etc.). However, it's the
72 HTTP is based on requests and responses - the client makes requests and servers
77 a file-like object, which means you can for example call ``.read()`` on the
87 schemes. For example, you can make an FTP request like so::
89 req = urllib.request.Request('ftp://example.com/')
94 the server - this information is sent as HTTP "headers". Let's look at each of
98 ----
113 url = 'http://www.someserver.com/cgi-bin/register.cgi'
125 forms - see `HTML Specification, Form Submission
126 <https://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13>`_ for more
131 "side-effects": they change the state of the system in some way (for example by
134 intended to *always* cause side-effects, and GET requests *never* to cause
135 side-effects, nothing prevents a GET request from having side-effects, nor a
136 POST requests from having no side-effects. Data can also be passed in an HTTP
158 -------
165 ``Python-urllib/x.y`` (where ``x`` and ``y`` are the major and minor version
167 e.g. ``Python-urllib/2.5``), which may confuse the site, or just plain
169 ``User-Agent`` header [#]_. When you create a Request object you can
177 url = 'http://www.someserver.com/cgi-bin/register.cgi'
182 headers = {'User-Agent': user_agent}
198 usual with Python APIs, built-in exceptions such as :exc:`ValueError`,
207 --------
225 ---------
244 codes in the 100--299 range indicate success, you will usually only see error
245 codes in the 400--599 range.
261 'Request accepted, processing continues off-line'),
262 203: ('Non-Authoritative Information', 'Request fulfilled from cache'),
268 'Object has several resources -- see URI list'),
269 301: ('Moved Permanently', 'Object moved permanently -- see URI list'),
270 302: ('Found', 'Object moved temporarily -- see URI list'),
271 303: ('See Other', 'Object moved -- see Method and URL list'),
278 'Object moved temporarily -- see URI list'),
283 'No permission -- see authorization schemes'),
285 'No payment -- see charging schemes'),
287 'Request forbidden -- authorization will not help'),
298 411: ('Length Required', 'Client must specify Content-Length.'),
301 414: ('Request-URI Too Long', 'URI is too long.'),
332 b'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
333 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n\n\n<html
339 --------------
342 basic approaches. I prefer the second approach.
398 **geturl** - this returns the real URL of the page fetched. This is useful
402 **info** - this returns a dictionary-like object that describes the page
406 Typical headers include 'Content-length', 'Content-type', and so on. See the
417 the default opener - via ``urlopen`` - but you can create custom
420 ftp, etc.), or how to handle an aspect of URL opening, for example HTTP
447 Basic Authentication
451 ``HTTPBasicAuthHandler``. For a more detailed discussion of this subject --
452 including an explanation of how Basic Authentication works - see the `Basic
458 and a 'realm'. The header looks like: ``WWW-Authenticate: SCHEME
463 .. code-block:: none
465 WWW-Authenticate: Basic realm="cPanel Users"
469 for the realm included as a header in the request. This is 'basic
483 The top-level URL is the first URL that requires authentication. URLs "deeper"
510 -- ``ProxyHandler`` (if a proxy setting such as an :envvar:`http_proxy`
520 NOT contain the "userinfo" component - for example ``"joe:password@example.com"`` is
527 **urllib** will auto-detect your proxy settings and use those. This is through
532 setting up a `Basic Authentication`_ handler: ::
575 -------
584 .. [#] Browser sniffing is a very bad practice for website design - building