Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
dab64260
Commit
dab64260
authored
Sep 19, 2010
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove references to read() and write() methods, which are useless synonyms of
recv() and send()
parent
792ff3e7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
28 deletions
+14
-28
Doc/library/ssl.rst
Doc/library/ssl.rst
+14
-28
No files found.
Doc/library/ssl.rst
View file @
dab64260
...
...
@@ -31,10 +31,9 @@ the documents in the "See Also" section at the bottom.
This module provides a class, :class:`ssl.SSLSocket`, which is derived from the
:class:`socket.socket` type, and provides a socket-like wrapper that also
encrypts and decrypts the data going over the socket with SSL. It supports
additional :meth:`read` and :meth:`write` methods, along with a method,
:meth:`getpeercert`, to retrieve the certificate of the other side of the
connection, and a method, :meth:`cipher`, to retrieve the cipher being used for
the secure connection.
additional methods such as :meth:`getpeercert`, which retrieves the
certificate of the other side of the connection, and :meth:`cipher`,which
retrieves the cipher being used for the secure connection.
For more sophisticated applications, the :class:`ssl.SSLContext` class
helps manage settings and certificates, which can then be inherited
...
...
@@ -131,10 +130,11 @@ Functions, Constants, and Exceptions
blocking behavior of the socket I/O involved in the handshake.
The parameter ``suppress_ragged_eofs`` specifies how the
:meth:`SSLSocket.re
ad
` method should signal unexpected EOF from the other end
:meth:`SSLSocket.re
cv
` method should signal unexpected EOF from the other end
of the connection. If specified as :const:`True` (the default), it returns a
normal EOF in response to unexpected EOF errors raised from the underlying
socket; if :const:`False`, it will raise the exceptions back to the caller.
normal EOF (an empty bytes object) in response to unexpected EOF errors
raised from the underlying socket; if :const:`False`, it will raise the
exceptions back to the caller.
.. versionchanged:: 3.2
New optional argument *ciphers*.
...
...
@@ -327,23 +327,10 @@ SSL Sockets
SSL sockets provide the basic interface of :ref:`socket-objects`. However,
not all functionality is supported (for example, passing a non-zero ``flags``
argument to :meth:`recv()` is not allowed).
argument to :meth:`
~socket.socket.
recv()` is not allowed).
SSL sockets also have the following additional methods and attributes:
.. method:: SSLSocket.read(nbytes=1024, buffer=None)
Reads up to ``nbytes`` bytes from the SSL-encrypted channel and returns them.
If the ``buffer`` is specified, it will attempt to read into the buffer the
minimum of the size of the buffer and ``nbytes``, if that is specified. If
no buffer is specified, an immutable buffer is allocated and returned with
the data read from the socket.
.. method:: SSLSocket.write(data)
Writes the ``data`` to the other side of the connection, using the SSL
channel to encrypt. Returns the number of bytes written.
.. method:: SSLSocket.do_handshake()
Performs the SSL setup handshake. If the socket is non-blocking, this method
...
...
@@ -699,11 +686,11 @@ certificate, sends some bytes, and reads part of the response::
print(pprint.pformat(ssl_sock.getpeercert()))
# Set a simple HTTP request -- use http.client in actual code.
ssl_sock.
write
(b"GET / HTTP/1.0\r\nHost: www.verisign.com\r\n\r\n")
ssl_sock.
sendall
(b"GET / HTTP/1.0\r\nHost: www.verisign.com\r\n\r\n")
# Read a chunk of data. Will not necessarily
# read all the data returned by the server.
data = ssl_sock.re
ad
()
data = ssl_sock.re
cv
()
# note that closing the SSLSocket will also close the underlying socket
ssl_sock.close()
...
...
@@ -761,9 +748,8 @@ host ``linuxfr.org``::
Now that you are assured of its authenticity, you can proceed to talk with
the server::
>>> conn.write(b"HEAD / HTTP/1.0\r\nHost: linuxfr.org\r\n\r\n")
38
>>> pprint.pprint(conn.read().split(b"\r\n"))
>>> conn.sendall(b"HEAD / HTTP/1.0\r\nHost: linuxfr.org\r\n\r\n")
>>> pprint.pprint(conn.recv(1024).split(b"\r\n"))
[b'HTTP/1.1 302 Found',
b'Date: Sun, 16 May 2010 13:43:28 GMT',
b'Server: Apache/2.2',
...
...
@@ -812,14 +798,14 @@ Then you'll read data from the ``connstream`` and do something with it till you
are finished with the client (or the client is finished with you)::
def deal_with_client(connstream):
data = connstream.re
ad(
)
data = connstream.re
cv(1024
)
# empty data means the client is finished with us
while data:
if not do_something(connstream, data):
# we'll assume do_something returns False
# when we're finished with client
break
data = connstream.re
ad(
)
data = connstream.re
cv(1024
)
# finished with client
And go back to listening for new client connections (of course, a real server
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment