Exemplo n.º 1
0
        public static Dictionary <string, string> GetFormData(this HttpListenerRequest req)
        {
            var dict    = new Dictionary <string, string>();
            var content = req.Content();

            if (content == null)
            {
                return(dict);
            }
            var parts = content.Split('&');

            foreach (var part in parts)
            {
                var kv = part.Split('=');
                var k  = kv[0];
                var v  = HttpUtility.UrlDecode(kv[1]);
                dict.Add(k, v);
            }
            return(dict);
        }
 public static T JsonToObject <T>(this HttpListenerRequest request)
 {
     return(SimpleJson.DeserializeObject <T>(request.Content()));
     //return JsonConvert.DeserializeObject<T>(request.Content());
 }
Exemplo n.º 3
0
 /// <summary>
 /// Dumps the specified req.
 /// </summary>
 /// <param name="req">The req.</param>
 /// <returns></returns>
 public static string Dump(this HttpListenerRequest req)
 {
     return(string.Format("->->->->-> REQUEST <-<-<-<-<-" + Environment.NewLine +
                          "->->->->-> Url: {0}" + Environment.NewLine +
                          "->->->->-> From: {1}" + Environment.NewLine +
                          "->->->->-> Method: {2}" + Environment.NewLine +
                          "->->->->-> Header: {3}" + Environment.NewLine +
                          "->->->->-> Content: {4}"
                          , req.Url, req.RemoteEndPoint.Address, req.HttpMethod, req.Headers.ToString(), req.Content()));
 }