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

Support additional content types in post requests #362

Open
ktrapeznikov opened this issue Nov 19, 2024 · 2 comments
Open

Support additional content types in post requests #362

ktrapeznikov opened this issue Nov 19, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@ktrapeznikov
Copy link

ktrapeznikov commented Nov 19, 2024


🚀 Feature

Add support to additional content-type requests such as application/octet-stream

Motivation

It will make the Litserv more flexible. It will also allow streaming binary data.

Pitch

Basically add another option to the lines here

if self.request_type == Request:

that returns request.body()

if self.request_type == Request:
        if request.headers["Content-Type"] == "application/x-www-form-urlencoded" or request.headers[
            "Content-Type"
        ].startswith("multipart/form-data"):
            payload = await request.form()
        elif request.headers["Content-Type"] == "application/octet-stream":
            payload = await request.body()
        else:
            payload = await request.json()

to support the following request

response = requests.post(API_URL, data = input_bytes, headers = {"Content-Type": "application/octet-stream"})

Alternatives

Additional context

@ktrapeznikov ktrapeznikov added the enhancement New feature or request label Nov 19, 2024
@ktrapeznikov ktrapeznikov changed the title Support addition content types in post requests Support additional content types in post requests Nov 19, 2024
@aniketmaurya
Copy link
Collaborator

aniketmaurya commented Nov 19, 2024

hi @ktrapeznikov, could you also share the use-case/example where you would need this format?

@ktrapeznikov
Copy link
Author

@aniketmaurya for example when using with amazon sagemaker async endpoint, an input provided as a location in an s3 bucket. AWS has some internal processors that read the file and sends it in a request. There is not much control on how the request is constructed. It basically just reads the file as bytes and sends in a body. It does not construct "multipart/form-data" request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants