PlatformHelper.SocketsHandler.cs 893 B

1234567891011121314151617181920212223242526272829303132
  1. using System.IO;
  2. using System.Threading;
  3. using System.Collections.Generic;
  4. using System.Net.Http.Headers;
  5. namespace System.Net.Http
  6. {
  7. static class PlatformHelper
  8. {
  9. internal static bool IsContentHeader (string name)
  10. {
  11. return HeaderDescriptor.TryGet (name, out var descriptor) && descriptor.HeaderType == HttpHeaderType.Content;
  12. }
  13. internal static string GetSingleHeaderString (string name, IEnumerable<string> values)
  14. {
  15. string separator = HttpHeaderParser.DefaultSeparator;
  16. if (HeaderDescriptor.TryGet (name, out var descriptor) &&
  17. (descriptor.Parser != null) && (descriptor.Parser.SupportsMultipleValues)) {
  18. separator = descriptor.Parser.Separator;
  19. }
  20. return string.Join (separator, values);
  21. }
  22. internal static StreamContent CreateStreamContent (Stream stream, CancellationToken cancellationToken)
  23. {
  24. return new StreamContent (stream);
  25. }
  26. }
  27. }