Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean up #39

Merged
merged 5 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
concurrency = multiprocessing
parallel = True
relative_files = True
source = tremolo
source = tremolo/
7 changes: 6 additions & 1 deletion .github/workflows/tests-and-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
path: artifact
if: ${{ matrix.python-version == '3.12' }}
report:
name: Upload Coverage to Codecov
name: Upload Coverage to Codecov & SonarCloud Scan
needs: ['tests']
runs-on: ubuntu-latest
steps:
Expand All @@ -75,4 +75,9 @@ jobs:
run: |
python -m coverage combine artifact
python -m coverage report --show-missing --skip-covered
python -m coverage xml
- uses: codecov/codecov-action@v3
- uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Tremolo

[![codecov](https://codecov.io/gh/nggit/tremolo/branch/master/graph/badge.svg?token=SC8NVWN0F1)](https://codecov.io/gh/nggit/tremolo)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=nggit_tremolo&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=nggit_tremolo)

Tremolo is a [stream-oriented](https://nggit.github.io/tremolo-docs/yield.html), asynchronous, programmable HTTP server written in pure Python. It can also serve as an [ASGI server](#asgi-server).

Expand Down Expand Up @@ -36,7 +37,7 @@ And other use cases…
## Features
Tremolo is only suitable for those who value [minimalism](https://en.wikipedia.org/wiki/Minimalism_%28computing%29) and stability over features.

With only 2500 lines of code, with no dependencies other than the [Python Standard Library](https://docs.python.org/3/library/index.html), it gives you:
With only 3K lines of code, with no dependencies other than the [Python Standard Library](https://docs.python.org/3/library/index.html), it gives you:

* HTTP/1.x with [WebSocket support](https://nggit.github.io/tremolo-docs/websocket.html)
* Keep-Alive connections with [configurable limit](https://nggit.github.io/tremolo-docs/configuration.html#keepalive_connections)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name='tremolo',
version='0.0.307',
version='0.0.308',
license='MIT',
author='nggit',
author_email='[email protected]',
Expand Down
4 changes: 4 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sonar.projectKey=nggit_tremolo
sonar.organization=nggit
sonar.sources=tremolo/
sonar.python.coverage.reportPaths=coverage.xml
2 changes: 1 addition & 1 deletion tremolo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '0.0.307'
__version__ = '0.0.308'

from .tremolo import Tremolo # noqa: E402
from . import exceptions # noqa: E402,F401
Expand Down
11 changes: 7 additions & 4 deletions tremolo/lib/http_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,7 @@ def query(self):

if self.query_string != b'':
self.params['query'] = parse_qs(
self.query_string.decode('latin-1'),
max_num_fields=100
self.query_string.decode('latin-1'), max_num_fields=100
)

return self.params['query']
Expand Down Expand Up @@ -345,15 +344,19 @@ async def files(self, limit=1024):
except StopAsyncIteration:
if header_size == -1 or body_size == -1:
del body[:]
raise BadRequest('malformed multipart/form-data')
raise BadRequest(
'malformed multipart/form-data: incomplete read'
)

if header is None:
self._read_buf.extend(data)
header_size = self._read_buf.find(b'\r\n\r\n')

if header_size == -1:
if len(self._read_buf) > 8192:
raise BadRequest('malformed multipart/form-data')
raise BadRequest(
'malformed multipart/form-data: header too large'
)

paused = False
else:
Expand Down