CheeseAPI 0.4.2__tar.gz → 0.4.5__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.
@@ -658,7 +658,8 @@ class Handle:
658
658
  })
659
659
 
660
660
  await protocol.server.message(**{
661
- 'message': message
661
+ 'message': message,
662
+ **protocol.kwargs
662
663
  })
663
664
 
664
665
  await self.websocket_afterMessage(protocol, message)
@@ -29,11 +29,6 @@ class HttpProtocol(asyncio.Protocol):
29
29
 
30
30
  try:
31
31
  self.parser.feed_data(data)
32
-
33
- if self.request.body:
34
- self.request._parseBody()
35
-
36
- asyncio.get_event_loop().create_task(app._handle.http(self))
37
32
  except httptools.HttpParserUpgrade:
38
33
  self.request._upgrade()
39
34
 
@@ -49,15 +44,22 @@ class HttpProtocol(asyncio.Protocol):
49
44
  self.request.headers['-'.join([t.capitalize() for t in key.decode().split('-')])] = value.decode()
50
45
 
51
46
  def on_headers_complete(self):
52
- self.request.client = self.request.headers.get('X-Real-Ip', None)
53
- self.request.origin = self.request.headers.get('Origin', None)
54
- self.request.scheme = self.request.headers.get('X-Forwarded-Proto', None)
47
+ self.request.client = self.request.headers.get('X-Real-Ip', self.transport.get_extra_info('socket').getpeername()[0])
48
+ self.request.origin = self.request.headers.get('Origin', f'{self.transport.get_extra_info("socket").getsockname()[0]}:{self.transport.get_extra_info("socket").getsockname()[1]}')
49
+ self.request.scheme = self.request.headers.get('X-Forwarded-Proto', 'https' if self.transport.get_extra_info('sslcontext') else 'http')
50
+
51
+ if not self.parser.should_upgrade() and not int(self.request.headers.get('Content-Length', 0)):
52
+ asyncio.get_event_loop().create_task(app._handle.http(self))
55
53
 
56
54
  def on_body(self, body: bytes):
57
55
  if self.request.body is None:
58
56
  self.request.body = b''
59
57
  self.request.body += body
60
58
 
59
+ if len(self.request.body) == int(self.request.headers.get('Content-Length', 0)):
60
+ self.request._parseBody()
61
+ asyncio.get_event_loop().create_task(app._handle.http(self))
62
+
61
63
  def connection_lost(self, exc: Exception | None):
62
64
  self.transport.close()
63
65
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: CheeseAPI
3
- Version: 0.4.2
3
+ Version: 0.4.5
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 = "0.4.2"
7
+ version = "0.4.5"
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