Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I specify multiple "Prefer" headers?

I'm currently building a Ruby SDK for the Graph API.

I'm working with delta queries on the message resource endpoints, specifically list-messages.

I need to specify two preferences utilizing the Prefer header(s):

  1. allow unsafe HTML - "outlook.allow-unsafe-html"
  2. maximum items per page/request - "odata.maxpagesize={num}"

There aren't any examples in the docs showing how this can be accomplished. I'm not sure whether they need to be concatenated into a single value or whether to specify multiple HTTP headers (or if this is even supported). Clarification here would be super helpful

like image 937
wulymammoth Avatar asked May 17 '19 23:05

wulymammoth


1 Answers

According to RFC7240:

A client MAY use multiple instances of the Prefer header field in a single message, or it MAY use a single Prefer header field with multiple comma-separated preference tokens. If multiple Prefer header fields are used, it is equivalent to a single Prefer header field with the comma-separated concatenation of all of the tokens.

So you can use multiple Prefer header fields defining distinct preferences:

 POST /foo HTTP/1.1
 Host: example.org
 Prefer: respond-async, wait=100
 Prefer: handling=lenient
 Date: Tue, 20 Dec 2011 12:34:56 GMT

Or you may use a single Prefer header field with a comma-separated list of values:

 POST /foo HTTP/1.1
 Host: example.org
 Prefer: handling=lenient, wait=100, respond-async
 Date: Tue, 20 Dec 2011 12:34:56 GMT
like image 192
Marc LaFleur Avatar answered Oct 06 '22 18:10

Marc LaFleur