Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 4 of 4 for uncompress (0.31 sec)

  1. docs/en/docs/how-to/custom-request-and-route.md

    First, we create a `GzipRequest` class, which will overwrite the `Request.body()` method to decompress the body in the presence of an appropriate header.
    
    If there's no `gzip` in the header, it will not try to decompress the body.
    
    That way, the same route class can handle gzip compressed or uncompressed requests.
    
    ```Python hl_lines="8-15"
    {!../../../docs_src/custom_request_and_route/tutorial001.py!}
    ```
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sun Mar 31 23:52:53 GMT 2024
    - 4.4K bytes
    - Viewed (0)
  2. .github/workflows/test-redistribute.yml

              # cache-dependency-path: pyproject.toml
          - name: Install build dependencies
            run: pip install build
          - name: Build source distribution
            run: python -m build --sdist
          - name: Decompress source distribution
            run: |
              cd dist
              tar xvf fastapi*.tar.gz
          - name: Install test dependencies
            run: |
              cd dist/fastapi-*/
    Others
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Mar 28 23:28:07 GMT 2024
    - 1.4K bytes
    - Viewed (0)
  3. docs_src/custom_request_and_route/tutorial001.py

        async def body(self) -> bytes:
            if not hasattr(self, "_body"):
                body = await super().body()
                if "gzip" in self.headers.getlist("Content-Encoding"):
                    body = gzip.decompress(body)
                self._body = body
            return self._body
    
    
    class GzipRoute(APIRoute):
        def get_route_handler(self) -> Callable:
            original_route_handler = super().get_route_handler()
    
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri May 13 23:38:22 GMT 2022
    - 973 bytes
    - Viewed (0)
  4. tests/test_tutorial/test_custom_request_and_route/test_tutorial001.py

        return {"request_class": type(request).__name__}
    
    
    client = TestClient(app)
    
    
    @pytest.mark.parametrize("compress", [True, False])
    def test_gzip_request(compress):
        n = 1000
        headers = {}
        body = [1] * n
        data = json.dumps(body).encode()
        if compress:
            data = gzip.compress(data)
            headers["Content-Encoding"] = "gzip"
        headers["Content-Type"] = "application/json"
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sun Nov 13 14:26:09 GMT 2022
    - 886 bytes
    - Viewed (0)
Back to top