CheeseAPI 1.2.0__tar.gz → 1.2.1__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.
@@ -361,7 +361,7 @@ class Handle:
361
361
 
362
362
  async def http_static(self, protocol: 'HttpProtocol'):
363
363
  if self._app.server.static and self._app.workspace.static and protocol.request.path.startswith(self._app.server.static) and protocol.request.method == http.HTTPMethod.GET:
364
- for key in [ '', '.html', 'index.html', '/index.html' ]:
364
+ for key in [ '', '.html', '/index.html' ]:
365
365
  try:
366
366
  protocol.response = FileResponse(os.path.join(self._app.workspace.static, protocol.request.path[1:] + key))
367
367
 
@@ -54,9 +54,6 @@ class HttpProtocol(asyncio.Protocol):
54
54
  t.split('=')[0]: t.split('=')[1] for t in self.request.headers['Cookie'].split('; ')
55
55
  }
56
56
 
57
- if not self.parser.should_upgrade() and not int(self.request.headers.get('Content-Length', 0)):
58
- asyncio.get_event_loop().create_task(app._handle.http(self))
59
-
60
57
  def on_body(self, body: bytes):
61
58
  if self.request.body is None:
62
59
  self.request._body = b''
@@ -397,7 +397,7 @@ class BaseResponse:
397
397
  elif isinstance(self.body, str):
398
398
  _value = self.body.encode()
399
399
  elif isinstance(self.body, bytes):
400
- _value += self.body
400
+ _value = self.body
401
401
  if _value:
402
402
  value += b'%x\r\n' % len(_value) + _value + b'\r\n0\r\n\r\n'
403
403
 
@@ -40,7 +40,7 @@ class Validator:
40
40
  *,
41
41
  required: bool = False,
42
42
  default: Any = None,
43
- type: List[object | Callable] | object | Callable = str,
43
+ type: List[object | Callable] | object | Callable = None,
44
44
  expected_type: str | None = None,
45
45
  pattern: str | None = None,
46
46
  min: object | None = None,
@@ -101,7 +101,7 @@ class Validator:
101
101
  self._scope: Literal['form', 'headers', 'args', 'path', 'cookie'] = scope
102
102
  self.key: str = key
103
103
  self._type: List[object | Callable] | object | Callable = type
104
- self._expected_type: str = type.__name__ if expected_type is None else expected_type
104
+ self._expected_type: str | None = type.__name__ if expected_type is None and self._type is not None else expected_type
105
105
  self.required: bool = required
106
106
  self._default: Any = default
107
107
  self._pattern: str | None = pattern
@@ -124,7 +124,8 @@ class Validator:
124
124
  if self.required:
125
125
  raise ValidateError(self.response or Response(app._text.validator_requiredMessage(self.scope, self.key), 400))
126
126
  validatedForm[f'{self.scope}.{self.key}'] = self.default
127
- else:
127
+
128
+ if validatedForm[f'{self.scope}.{self.key}'] is not None:
128
129
  if self.type is not None:
129
130
  try:
130
131
  if isinstance(self.type, list):
@@ -203,7 +204,7 @@ class Validator:
203
204
 
204
205
  @expected_type.setter
205
206
  def expected_type(self, value: str | None):
206
- self._expected_type = self.type.__name__ if value is None else value
207
+ self._expected_type = self.type.__name__ if value is None and self.type is not None else value
207
208
 
208
209
  @property
209
210
  def default(self) -> Any:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: CheeseAPI
3
- Version: 1.2.0
3
+ Version: 1.2.1
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.2.0"
7
+ version = "1.2.1"
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