HeaderUtils.SocketsHandler.cs 697 B

12345678910111213141516171819202122232425
  1. using System.Collections.Generic;
  2. using System.Net.Http.Headers;
  3. namespace System.Net.Http
  4. {
  5. static class HeaderUtils
  6. {
  7. internal static bool IsContentHeader (string name)
  8. {
  9. return HeaderDescriptor.TryGet (name, out var descriptor) && descriptor.HeaderType == HttpHeaderType.Content;
  10. }
  11. internal static string GetSingleHeaderString (string name, IEnumerable<string> values)
  12. {
  13. string separator = HttpHeaderParser.DefaultSeparator;
  14. if (HeaderDescriptor.TryGet (name, out var descriptor) &&
  15. (descriptor.Parser != null) && (descriptor.Parser.SupportsMultipleValues)) {
  16. separator = descriptor.Parser.Separator;
  17. }
  18. return string.Join (separator, values);
  19. }
  20. }
  21. }