コード例 #1
0
ファイル: AtHttpProtocol.cs プロジェクト: lulianqi/AutoTest
 /// <summary>
 /// i will Send Data with multipart,if you do not want updata any file you can set isFile is false and set filePath is null
 /// </summary>
 /// <param name="url">url</param>
 /// <param name="timeOut">timeOut</param>
 /// <param name="name">Parameter name</param>
 /// <param name="filename">filename</param>
 /// <param name="isFile">is a file</param>
 /// <param name="filePath">file path or cmd</param>
 /// <param name="bodyParameter">the other Parameter in body</param>
 /// <param name="myAht">the myAutoHttpTest will fill the data</param>
 /// <returns>back</returns>
 public void HttpPostData(string url, int timeOut, string name, string filename, bool isFile, string filePath, string bodyParameter, MyExecutionDeviceResult myEdr)
 {
     MyWebTool.MyHttpResponse httpResponse = myHttp.SendMultipartRequest(url, null, myHttp.IsWithDefaultCookieContainer, null, new List <MyWebTool.HttpMultipartDate>()
     {
         new MyWebTool.HttpMultipartDate(name, filename, null, isFile, filePath)
     }, bodyParameter, null, null, null);
     myEdr.backContent = isShowRawResponse ? httpResponse.ResponseRaw : httpResponse.ResponseBody;
     MyWebTool.HttpTimeLine timeline = httpResponse.TimeLine ?? new MyWebTool.HttpTimeLine();
     myEdr.startTime   = timeline.StartTime.ToString("HH:mm:ss");
     myEdr.requestTime = myEdr.spanTime = timeline.ElapsedTime.ToString();
 }
コード例 #2
0
        public static void DotestForMyhttp2()
        {
            MyWebTool.MyHttp myHttp = new MyWebTool.MyHttp(false, true);

            List <MyWebTool.HttpMultipartDate> hml = new List <MyWebTool.HttpMultipartDate>();

            hml.Add(new MyWebTool.HttpMultipartDate("multipart name", "file name", null, false, "test data"));
            hml.Add(new MyWebTool.HttpMultipartDate("multipart name", null, "comtenttype", false, "test data"));

            Console.WriteLine(myHttp.SendMultipartRequest("http://pv.sohu.com/cityjson?ie=utf-8", new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("name", "DotestForMyhttp")
            }, true, "body data", hml, null, null, null, null).ResponseBody);
            Console.WriteLine(myHttp.SendMultipartRequest("http://pv.sohu.com/cityjson?ie=utf-8", new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("name", "DotestForMyhttp")
            }, true, "body data", hml, "a=1&b=2&c=4", null, null, null).ResponseRaw);
            hml.Add(new MyWebTool.HttpMultipartDate("multipart name", "file name", "comtenttype", true, @"D:\shou1.txt"));
            Console.WriteLine(myHttp.SendMultipartRequest("http://pv.sohu.com/cityjson?ie=utf-8", new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("name", "DotestForMyhttp")
            }, true, "body data", hml, "a=1&b=2&c=4", null, null, null).ResponseBody);
        }