HeaderTool.cs 636 B

1234567891011121314151617181920212223
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net;
  5. using System.Text;
  6. namespace Azylee.YeahWeb.HttpUtils.MethodUtils.ExtendUtils
  7. {
  8. public static class HeaderTool
  9. {
  10. public static bool Set(ref HttpWebRequest request, Dictionary<string, string> headers)
  11. {
  12. try
  13. {
  14. if (request != null && headers != null && headers.Count > 0)
  15. foreach (var head in headers)
  16. request.Headers.Add(head.Key, head.Value);
  17. return true;
  18. }
  19. catch { return false; }
  20. }
  21. }
  22. }