CheeseAPI 1.3.1__tar.gz → 1.3.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37,7 +37,7 @@ class Request:
37
37
  self._method = 'WEBSOCKET'
38
38
 
39
39
  def _parseBody(self):
40
- if 'Content-Type' not in self.headers:
40
+ if 'Content-Type' not in self.headers or self.body is None:
41
41
  return
42
42
 
43
43
  if 'application/json' in self.headers['Content-Type']:
@@ -360,6 +360,7 @@ class BaseResponse:
360
360
  'Transfer-Encoding': 'chunked',
361
361
  **headers
362
362
  }
363
+ self.headers['Content-Type'] += '; charset=utf-8'
363
364
  self.body: str | bytes | Callable | AsyncIterator = self.status.description if body is None else body
364
365
  self._transfering: bool = False
365
366
 
@@ -464,7 +465,7 @@ class JsonResponse(BaseResponse):
464
465
 
465
466
  def __init__(self, body: dict | list = {}, status: http.HTTPStatus | int = http.HTTPStatus.OK, headers: Dict[str, str] = {}):
466
467
  super().__init__(json.dumps(body), status, {
467
- 'Content-Type': 'application/json; charset=utf-8',
468
+ 'Content-Type': 'application/json',
468
469
  **headers
469
470
  })
470
471
 
@@ -33,3 +33,7 @@ class Server:
33
33
  '''
34
34
 
35
35
  return self._intervalTime
36
+
37
+ @intervalTime.setter
38
+ def intervalTime(self, value: float):
39
+ self._intervalTime = value
@@ -62,18 +62,20 @@ def validator(validator: BaseModel):
62
62
 
63
63
  _kwargs = {}
64
64
  for key in validator.model_fields.keys():
65
- _kwargs[key] = None
66
-
67
65
  for scope in [ 'path', 'args', 'form', 'cookie', 'headers' ]:
68
66
  try:
69
67
  if scope == 'path':
70
- _kwargs[key] = kwargs.get(key)
68
+ _kwargs[key] = kwargs[key]
71
69
  elif scope == 'headers':
72
- _kwargs[key] = getattr(request, scope).get(key.replace('_', '-'))
70
+ _kwargs[key] = getattr(request, scope)[key.replace('_', '-')]
73
71
  else:
74
- _kwargs[key] = getattr(request, scope).get(key)
72
+ _kwargs[key] = getattr(request, scope)[key]
75
73
 
76
74
  if _kwargs.get(key):
75
+ try:
76
+ _kwargs[key] = json.loads(_kwargs[key])
77
+ except:
78
+ ...
77
79
  break
78
80
  except:
79
81
  ...
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: CheeseAPI
3
- Version: 1.3.1
3
+ Version: 1.3.3
4
4
  Summary: 一款web协程框架。
5
5
  Project-URL: Source, https://github.com/CheeseUnknown/CheeseAPI
6
6
  Author-email: Cheese Unknown <cheese@cheese.ren>
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "CheeseAPI"
7
- version = "1.3.1"
7
+ version = "1.3.3"
8
8
  description = "一款web协程框架。"
9
9
  readme = "README.md"
10
10
  license-files = { paths = [ "LICENSE" ] }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes