Questions related to the HTTP Accept header, which defines the content types the client advertises it will accept.
Questions tagged [http-accept-header]
79 questions
1
vote
1 answer
Is Access-Control-Allow-Origin required for the preflight AND the actual request?
I am implementing a router to process all web requests.
OPTIONS requests come in and I am responding with:
header('Access-Control-Allow-Origin: http://localhost:4000');
header('Access-Control-Allow-Methods: GET, POST, PUT,…

William Entriken
- 37,208
- 23
- 149
- 195
1
vote
0 answers
REST Response adds \ - Media Type application/json vs text/plain
I have an endpoint that returns the following response,
curl -X 'POST' \
'https://localhost:7135/api/v1/Initiate' \
-H 'accept: application/json' \
-H 'Content-Type: application/json'
returns
"{\"ID\":\"987139672\"}"
Notice the \ after key…

tRuEsAtM
- 3,517
- 6
- 43
- 83
1
vote
1 answer
How can i make the page accept the mimetype in asp.net
I have my own webshop set up with a payment provider and to finalize the buy they send me a post to a page with some data for me to acknowledge the order.
The problem is that when they do the request it returns a 406 error for them. This is what i…

Jimmy
- 275
- 2
- 6
- 27
1
vote
1 answer
Why RequestMappings with the same URL but producing different MediaTypes works?
I want to understand why Spring application is starting if I have same 2 requestMapping URL,params(no params) and produces type(JSON).By default the methods is producing JSON(I tested XML and others and I get 500 error, I don't have dependencies).I…

Cleo
- 136
- 1
- 10
1
vote
1 answer
"accept-ranges" header set to "none" instead of "bytes"
I was getting following response after making a curl request to an endpoint
HTTP/2 200
date: Mon, 24 Jun 2019 10:11:39 GMT
content-type: text/html; charset=UTF-8
content-length: 1952
server: nginx
x-powered-by: Express
cache-control: public,…

Tanay Suthar
- 453
- 3
- 8
- 19
1
vote
0 answers
How can I stop sending accept-headers?
My client send to service Accept-Headers: gzip,deflate and the service is sending gzip to me. So I need stop sending Accept-Headers:gzip, deflate from my side. I am using .Net Core 2.1.
Is there any way to do it?

Martin B
- 31
- 6
1
vote
1 answer
specify and test htaccess HTTP_ACCEPT
When I test my .htaccess with
curl -H "Accept: application/rdf+xml" -L http://localhost/v0.1
curl -H "Accept: application/rdf+xml" -L http://localhost/v1.0
This works
RewriteRule ^v0\.1$…

Mzq
- 1,796
- 4
- 30
- 65
1
vote
1 answer
How to use built-in xml or json formatter for custom accept header value in .Net Core 2.0
Update:
I have uploaded a small test project to github: link
I am creating a small web service with .Net Core 2, and would like to give the ability to clients to specify if they need navigational info in the response or not. The web api should only…

Daniel
- 153
- 3
- 16
1
vote
0 answers
What is wrong with this accept header? And what are the rules?
I have an Accept header like this:
application/myapp+json;version=2.0
however when I try and use it the constructor for System.Net.Http.Headers.MediaTypeWithQualityHeaderValue rejects it as invalid. Nancy doesn't seem to mind it.
It seems it…

Sam Holder
- 32,535
- 13
- 101
- 181
1
vote
1 answer
Usage for profile parameter for JSON-LD requests
The documentation of JSON-LD mentions that clients can provide a profile parameter to the Accept header can be used to control the representation. It defines the three defaults for requesting compacted, expanded or flattened JSON-LD documents. It…

Tomasz Pluskiewicz
- 3,622
- 1
- 19
- 42
1
vote
1 answer
Swagger-UI Response Content Type
Is it possible to add the Response Content Type select box without creating the Response Class (Status 200) schema?
My web services return JSON or XML format depending on the accept header. I need this dropdown after that.

John
- 4,711
- 9
- 51
- 101
1
vote
1 answer
What does "+" means in HTTP Accept header?
How could I understand this record:
Accept: application/vnd.my.api+json
I mean, is this "+" symbol is standartized (anyway, I have not find it in spec), or it is just a convention?
Thanks.

Sergey Kamardin
- 1,640
- 1
- 18
- 22
1
vote
1 answer
Extending Illuminate\Http\Request clears Accept header
I've extended the Illuminate\Http\Request class and am passing it along to my controller.
In my controller, I check if the request has an Accept: application/json header, using the $request->wantsJson() method.
If I use the base…

andrewtweber
- 24,520
- 22
- 88
- 110
1
vote
0 answers
Adding compression to fonts
I get this warning in a speed test from tools.pingdom.com: compressible resources should have a "Vary: Accept-Encoding" header
How can I compress this resource on my site: http://www.abrakadabra.fi/fonts/fontawesome-webfont.woff2
I serve these fonts…

Kim Wist
- 69
- 1
- 8
1
vote
1 answer
Arbitrating Jersey endpoints based on Accept headers: what when no Accept header is given?
Suppose I have two endpoints that look like this:
@GET
@Path("/blah")
@Produces(MIME_TYPE_1)
public Thing getThing() {
....
}
@GET
@Path("/blah")
@Produces(MIME_TYPE_2)
public OtherThing getOtherThing() {
....
}
This works very well for…

chiastic-security
- 20,430
- 4
- 39
- 67