BlackSheep icon indicating copy to clipboard operation
BlackSheep copied to clipboard

Add support for ASGI pathsend

Open gi0baro opened this issue 6 months ago • 5 comments

Close #569

gi0baro avatar May 30 '25 08:05 gi0baro

@RobertoPrevato regarding tests, do you have any advice? I don't see any specific tests for the scribe module. Should I just add a test in test_responses for this?

gi0baro avatar May 30 '25 08:05 gi0baro

Thanks @gi0baro for contributing! Regarding tests, I didn't include tests specific to the scribe namespace because most functions of the Cython code are defined as cdef for best performance, and cannot be imported from Python code. Yes, I would probably add more tests to test_responses, or add a dedicated module for this feature if that makes sense.

RobertoPrevato avatar Jun 08 '25 18:06 RobertoPrevato

Thanks @gi0baro, Sorry for taking such a long time to come back to this. ~~I understand your PR is complete and can be merged, correct?~~ I plan to release a new version to PyPi this weekend.

I just tested with Granian and it seems to fail serving files (unless I am doing something wrong). Please let me know if I can help with anything for this PR.

RobertoPrevato avatar Sep 27 '25 12:09 RobertoPrevato

Hey @RobertoPrevato

I'm the one who actually feels sorry for this; I hadn't chance to continue working on this since my last comment. The current implementation kinda provides the low-level requirements for pathsend to work, but this is definitely missing:

  • tests
  • user-facing implementations (that should relay on the current work) like
    • app.serve_files
    • blacksheep.server.responses.file

I'm not sure I'll have time to work on this in the near future, but I can get back to you as soon as I have some time.

To add a bit of context, essentially this should produce a different set of ASGI response messages for files coming from an existing path when the ASGI scope mention the extension availability.

gi0baro avatar Sep 29 '25 15:09 gi0baro

Hi @gi0baro No worries, and thank you again for your help.

RobertoPrevato avatar Oct 01 '25 07:10 RobertoPrevato