Skip to content

Conversation

avalon1610
Copy link

Motivation

This change enables the use of Form as an optional extractor in certain scenarios.

Solution

This PR implements OptionalFromRequest for Form and RawForm. The behavior is as follows:

  • For GET or HEAD requests, if there are no query parameters, the extractor will return None. Otherwise, it will parse the form data using the original logic.
  • For other HTTP methods, if the Content-Type header is not present, the extractor will return None. Otherwise, it will parse the form data using the original logic.

Additionally, the FromRequest implementation for RawForm does not include a check for the HEAD method. I believe this is a bug, as Form and RawForm should behave consistently. Is this understanding correct?

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

Successfully merging this pull request may close these issues.

1 participant