Skip to content

Commit

Permalink
Renaming and code simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Mar 21, 2020
1 parent a5fc32c commit fedd191
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/netius/clients/mjpg.py
Expand Up @@ -46,9 +46,9 @@
class MJPGProtocol(http.HTTPProtocol):

MAGIC_JPEG = b"\xff\xd8\xff\xe0"
""" The magic signature for the jpeg infra-structure, this
""" The magic signature for the JPEG infra-structure, this
sequence of bytes is going to be used to detect new frames
coming from the http based stream """
coming from the HTTP based stream """

EOI_JPEG = b"\xff\xd9"
""" The sequence of bytes that indicate the end of the current
Expand Down
2 changes: 1 addition & 1 deletion src/netius/common/geo.py
Expand Up @@ -50,7 +50,7 @@ class GeoResolver(object):
information database (to be used in execution) """

DOWNLOAD_URL = "https://files.bemisc.com/maxmind/GeoLite2-City.mmdb.gz"
""" The url to the compressed version of the GeoIP
""" The URL to the compressed version of the GeoIP
city database used for resolution """

VALID = ("continent", "country", "city", "location")
Expand Down
1 change: 0 additions & 1 deletion src/netius/common/http2.py
Expand Up @@ -44,7 +44,6 @@
import netius

from . import http
from . import util
from . import parser

HEADER_SIZE = 9
Expand Down
8 changes: 4 additions & 4 deletions src/netius/extra/proxy_r.py
Expand Up @@ -285,7 +285,7 @@ def on_headers(self, connection, parser):
)

# verifies if the current host requires some kind of special authorization
# process using the default basic http authorization process
# process using the default basic HTTP authorization process
auth = self.auth.get(DEFAULT_NAME, None)
auth = self.auth.get(host, auth)
auth = self.auth.get(host_s, auth)
Expand Down Expand Up @@ -378,7 +378,7 @@ def on_headers(self, connection, parser):
# verifies if the current connection already contains a valid
# a proxy connection if that's the case that must be unset from
# the connection and from the connection map internal structures
# at least until the http client returns from the method call
# at least until the HTTP client returns from the method call
proxy_c = hasattr(connection, "proxy_c") and connection.proxy_c
proxy_c = proxy_c or None
connection.proxy_c = None
Expand All @@ -393,7 +393,7 @@ def on_headers(self, connection, parser):

# calls the proper (HTTP) method in the client this should acquire
# a new connection and start the process of sending the request
# to the associated http server (request handling)
# to the associated HTTP server (request handling)
_connection = self.http_client.method(
method,
url,
Expand Down Expand Up @@ -425,7 +425,7 @@ def on_headers(self, connection, parser):
# not been yet established (no data has been received)
self.debug("Setting connection as waiting, proxy connection loading ...")

# sets the current http back-end client connection as waiting and then
# sets the current HTTP back-end client connection as waiting and then
# maps it as the proxy connection in the connection and also creates
# the reverse mapping using the connection map of the current server
_connection.waiting = True
Expand Down
6 changes: 3 additions & 3 deletions src/netius/servers/http.py
Expand Up @@ -370,7 +370,7 @@ def send_header(
)

# "notifies" the owner of the connection that the headers have been
# sent all the http header information should be present
# sent all the HTTP header information should be present
self.owner.on_send_http(
self.connection_ctx,
self.parser_ctx,
Expand Down Expand Up @@ -403,12 +403,12 @@ def parse(self, data):
def resolve_encoding(self, parser):
# in case the "target" encoding is the plain one nothing
# is required to be done as this is allowed by any kind
# of http compliant connection (returns immediately)
# of HTTP compliant connection (returns immediately)
if self.encoding == PLAIN_ENCODING:
self.current = PLAIN_ENCODING

# if the target encoding is chunked must verify if the
# type of http connection in question is 1.1 or above
# type of HTTP connection in question is 1.1 or above
# otherwise must down-grade the encoding to plain
elif self.encoding == CHUNKED_ENCODING:
if parser.version < netius.common.HTTP_11:
Expand Down
2 changes: 1 addition & 1 deletion src/netius/servers/http2.py
Expand Up @@ -412,7 +412,7 @@ def callback(connection):
)

# "notifies" the owner of the connection that the headers have been
# sent all the http header information should be present
# sent all the HTTP header information should be present
self.owner.on_send_http(
self.connection_ctx,
self.parser_ctx,
Expand Down
6 changes: 3 additions & 3 deletions src/netius/servers/proxy.py
Expand Up @@ -206,7 +206,7 @@ def on_data(self, connection, data):

# tries to retrieve the reference to the tunnel connection
# currently set in the connection in case it does not exists
# (initial handshake or http client proxy) runs the parse
# (initial handshake or HTTP client proxy) runs the parse
# step on the data and then returns immediately
tunnel_c = hasattr(connection, "tunnel_c") and connection.tunnel_c
if not tunnel_c: connection.parse(data); return
Expand Down Expand Up @@ -343,7 +343,7 @@ def _raw_throttle(self, connection):

def _on_prx_headers(self, client, parser, headers):
# retrieves the owner of the parser as the client connection
# and then retrieves all the other http specific values
# and then retrieves all the other HTTP specific values
_connection = parser.owner
code_s = parser.code_s
status_s = parser.status_s
Expand Down Expand Up @@ -588,7 +588,7 @@ def _apply_via(self, parser_prx, headers):

# tries to retrieve the current via string (may already exits)
# and appends the created string to the base string or creates
# a new one (as defined in the http specification)
# a new one (as defined in the HTTP specification)
via = headers.get("Via", "")
if via: via += ", "
via += via_s
Expand Down
4 changes: 2 additions & 2 deletions src/netius/servers/torrent.py
Expand Up @@ -598,12 +598,12 @@ def peers_tracker(self):
# the various trackers from each of them
for tracker_url in tracker:
# retrieves the first element of the tracker structure as the
# url of it and then verifies that it references an http based
# URL of it and then verifies that it references an HTTP based
# tracker (as that's the only one supported)
is_http = tracker_url.startswith(("http://", "https://"))
if not is_http: continue

# runs the get http retrieval call (blocking call) so that it's
# runs the get HTTP retrieval call (blocking call) so that it's
# possible to retrieve the contents for the announce of the tracker
# this is an asynchronous call and the on tracker callback will be
# called at the end of the process with the message
Expand Down
2 changes: 1 addition & 1 deletion src/netius/servers/ws.py
Expand Up @@ -140,7 +140,7 @@ def on_data(self, connection, data):
netius.StreamServer.on_data(self, connection, data)

# iterates while there's still data pending to be parsed from the
# current message received using the http or ws protocols
# current message received using the HTTP or WS protocols
while data:
if connection.handshake:
# retrieves the current (pending) buffer of data for the
Expand Down

0 comments on commit fedd191

Please sign in to comment.