Advertisement
Guest User

StringRequestParameter

a guest
Mar 29th, 2014
643
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.76 KB | None | 0 0
  1. namespace Zelka.Apis
  2. {
  3.     using System.IO;
  4.     using System.Text;
  5.  
  6.     public class StringRequestParameter : IRequestParameter
  7.     {
  8.         public StringRequestParameter(string key, string value)
  9.         {
  10.             this.Key = key;
  11.             this.Value = value;
  12.         }
  13.  
  14.         public string Value { get; set; }
  15.  
  16.         public string Key { get; set; }
  17.  
  18.         public void WriteToStream(Stream stream, string boundary, Encoding encoding)
  19.         {
  20.             const string template = "--{0}\r\nContent-Disposition: form-data; name=\"{1}\"\r\n\r\n{2}";
  21.             string postData = string.Format(template, boundary, this.Key, this.Value);
  22.  
  23.             stream.Write(encoding.GetBytes(postData), 0, encoding.GetByteCount(postData));
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement