Skip to content

Commit

Permalink
Fix MergeIndividualAndBatchPreferences method (#2377)
Browse files Browse the repository at this point in the history
* Fix MergeIndividualAndBatchPreferences method
for same Prefer headers case (bug with an unnecessary comma at the end of line)

* Add test merging same Prefer header while processing batch.

Co-authored-by: Tsar Nikolay <[email protected]>
  • Loading branch information
bratchikov and Tsar Nikolay authored Dec 23, 2020
1 parent 122cab1 commit d71f708
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,11 @@ private static string MergeIndividualAndBatchPreferences(string individualPrefer
.Where(pref => !individualPreferenceNames.Contains(pref.Split('=').FirstOrDefault()));
string filteredBatchPreferences = string.Join(",", filteredBatchList);

if (string.IsNullOrEmpty(filteredBatchPreferences))
{
return individualPreferences;
}

return string.Join(",", individualPreferences, filteredBatchPreferences);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,16 @@ public async Task SendAsync_Works_ForBatchRequestWithInsertedEntityReferencedInA
"DELETE,ContentType=,ContentLength=,Prefer=wait=100,handling=lenient",
"POST,ContentType=text/plain; charset=utf-8,ContentLength=3,Prefer="
},
{
// should not concatenate preferences that should not be inherited
new []
{
"wait=100,handling=lenient"
},
"GET,ContentType=,ContentLength=,Prefer=",
"DELETE,ContentType=,ContentLength=,Prefer=wait=100,handling=lenient",
"POST,ContentType=text/plain; charset=utf-8,ContentLength=3,Prefer="
},
{
// inheritable preferences should be copied over
// and combined with the individual request's own preferences if any
Expand Down

0 comments on commit d71f708

Please sign in to comment.