예제 #1
0
 private void SendBody(HttpListenerResponse aspNetResponse, IDictionary <string, string> wireResponse)
 {
     using (var stream = aspNetResponse.OutputStream)
     {
         var formParams = new FormParams.Of(wireResponse);
         if (formParams.Count > 0)
         {
             using (var body =
                        new InputOf(
                            new Yaapii.Atoms.Text.Joined("&",
                                                         new Mapped <KeyValuePair <string, string>, string>(kvp =>
                                                                                                            $"{kvp.Key}={kvp.Value}",
                                                                                                            formParams
                                                                                                            )
                                                         )
                            ).Stream()
                    )
             {
                 body.CopyTo(stream);
             }
         }
         else if (new Body.Exists(wireResponse).Value())
         {
             using (var body = new Body.Of(wireResponse).Stream())
             {
                 body.CopyTo(stream);
             }
         }
     }
 }
        private HttpContent FormContent(IDictionary <string, string> request)
        {
            var content = new FormParams.Of(request);

            return
                (new FormUrlEncodedContent(
                     new Mapped <string, KeyValuePair <string, string> >(key =>
                                                                         new KeyValuePair <string, string>(key, content[key]),
                                                                         content.Keys
                                                                         )
                     ));
        }