Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

ConsumesAttributes accepts requests without content type #8174

Closed
amrmahdi opened this issue Jul 30, 2018 · 2 comments
Closed

ConsumesAttributes accepts requests without content type #8174

amrmahdi opened this issue Jul 30, 2018 · 2 comments
Assignees
Labels
3 - Done bug cost: XS Will take up to half a day to complete PRI: 1 - Required Must be handled in a reasonable time

Comments

@amrmahdi
Copy link

Is this a Bug or Feature request?:

Bug ?

Steps to reproduce (preferably a link to a GitHub repo with a repro project):

Define an action decorated with a specific content type, and send a request with no content type header.

Description of the problem:

We are using the ConsumesAttribute to constraint the content types an action accepts. We found out that if there is not content type header is sent, the action still gets the requests.

Looking at the attribute code, I can see that the validation only happens if the content type is not null

if (requestContentType != null && !IsSubsetOfAnyContentType(requestContentType))

Should the request be reqjected if the content type is null ?

Version of Microsoft.AspNetCore.Mvc or Microsoft.AspNetCore.App or Microsoft.AspNetCore.All:

2.1.2

@mkArtakMSFT mkArtakMSFT added bug 1 - Ready PRI: 1 - Required Must be handled in a reasonable time labels Jul 31, 2018
@mkArtakMSFT mkArtakMSFT added this to the 2.2.0-preview1 milestone Jul 31, 2018
@mkArtakMSFT
Copy link
Member

@rynowak, do you think this fix should go behind a back compat switch?
/cc @danroth27

@rynowak
Copy link
Member

rynowak commented Jul 31, 2018

No, I don't this is high profile enough for a compat switch.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
3 - Done bug cost: XS Will take up to half a day to complete PRI: 1 - Required Must be handled in a reasonable time
Projects
None yet
Development

No branches or pull requests

4 participants