HTTPFieldData.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace BestHTTP.Forms
  6. {
  7. /// <summary>
  8. /// This class represents a HTTP Form's field.
  9. /// </summary>
  10. public class HTTPFieldData
  11. {
  12. /// <summary>
  13. /// The form's field.
  14. /// </summary>
  15. public string Name { get; set; }
  16. /// <summary>
  17. /// Filename of the field. Optional.
  18. /// </summary>
  19. public string FileName { get; set; }
  20. /// <summary>
  21. /// Mime-type of the field. Optional
  22. /// </summary>
  23. public string MimeType { get; set; }
  24. /// <summary>
  25. /// Encoding of the data. Optional
  26. /// </summary>
  27. public Encoding Encoding { get; set; }
  28. /// <summary>
  29. /// The field's textual data.
  30. /// </summary>
  31. public string Text { get; set; }
  32. /// <summary>
  33. /// The field's binary data.
  34. /// </summary>
  35. public byte[] Binary { get; set; }
  36. /// <summary>
  37. /// Will return with the binary data, or if it's not present the textual data will be decoded to binary.
  38. /// </summary>
  39. public byte[] Payload
  40. {
  41. get
  42. {
  43. if (Binary != null)
  44. return Binary;
  45. if (Encoding == null)
  46. Encoding = Encoding.UTF8;
  47. return Binary = Encoding.GetBytes(Text);
  48. }
  49. }
  50. }
  51. }