lulianqi commented on code in PR #1:
URL: https://github.com/apache/dubbo-net/pull/1#discussion_r4421798272


##########
Clients/DubboClient.cs:
##########
@@ -0,0 +1,1572 @@
+using DubboNet.Clients.DataModle;

Review Comment:
   历史工具清理后当前有 73 个 C# 源文件,其中 3 个新增文件含 ASF header,70 个历史文件仍待 #2 
处理。四个有争议且未使用的来源文件已删除,只剩在用 ExTelnet.cs 的来源需要明确;本轮没有擅自给其重标版权,也没有把手动 license 
审计改成虚假的自动通过门禁。文件头事项仍保持开放。



##########
MyCommonHelper/EncryptionHelper/MyRSA.cs:
##########
@@ -0,0 +1,292 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Security.Cryptography;
+using System.Text;
+
+namespace MyCommonHelper.EncryptionHelper
+{
+    public class MyRSA
+    {
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="PlainText"></param>
+        /// <param name="modulus">n (p*q) [Big Endian]</param>
+        /// <param name="publicExponent">e,公共指数 [Big Endian]</param>
+        /// <returns></returns>
+        public static byte[] Encrypt(byte[] PlainText, byte[] modulus,byte[] 
publicExponent)
+        {
+            if(PlainText==null || modulus==null || publicExponent==null)
+            {
+                new ArgumentNullException("Argument Is Null");

Review Comment:
   已在 c95ae8a 按删除方案移除整个 MyRSA 类,不再分发缺少 
throw、吞异常和旧密码校验等代码。程序集类型缺失回归测试及其余全量测试通过(309 passed)。



##########
NetService/MyWebTool.cs:
##########
@@ -0,0 +1,1106 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Diagnostics;
+using System.Net;
+using System.IO;
+using System.Collections.Specialized;
+using System.Linq;
+using System.Security.Cryptography.X509Certificates;
+
+
+/*******************************************************************************
+* Copyright (c) 2015 lijie
+* All rights reserved.
+* 
+* 文件名称: 
+* 内容摘要: [email protected]
+* 
+* 历史记录:
+* 日      期:   201505016           创建人: 李杰 15158155511
+* 描    述: 创建  (this file is from 
https://github.com/lulianqi/AutoTest/blob/master/AutoTest/MyCommonHelper/NetHelper/MyWebTool.cs)
+*******************************************************************************/
+
+
+//from  
https://github.com/lulianqi/AutoTest/blob/master/AutoTest/MyCommonHelper/NetHelper/MyWebTool.cs
+namespace NetService.WebService
+{
+    public class MyWebTool
+    {
+        public class HttpMultipartDate
+        {
+            /** eg:
+            -----------------8d46c074125a195
+            Content-Disposition: form-data; name="name"; filename="filenmae"
+            Content-Type: application/octet-stream
+
+            testdata
+            -----------------8d46c074125a195--
+             * */
+
+            /// <summary>
+            /// name属性值,为null则不加
+            /// </summary>
+            public string Name { get; set; }
+            /// <summary>
+            /// filename属性值,为null则不加
+            /// </summary>
+            public string FileName { get; set; }
+            /// <summary>
+            /// Multipart下Content-Type: application/octet-stream,为null则不加
+            /// </summary>
+            public string ContentType { get; set; }
+            /// <summary>
+            /// 是否把fileData当作文件路径处理
+            /// </summary>
+            public bool IsFile { get; set; }
+            /// <summary>
+            /// 文件内容或文件路径。为null则当作""
+            /// </summary>
+            public string FileData { get; set; }
+            public HttpMultipartDate()
+            {
+                Name = FileName = ContentType = FileData = null;
+            }
+
+            /// <summary>
+            /// 初始化 HttpMultipartDate
+            /// </summary>
+            /// <param name="yourName">name属性值,为null则不加</param>
+            /// <param name="yourFileName">filename属性值,为null则不加</param>
+            /// <param name="yourContentType">Multipart下Content-Type: 
application/octet-stream,为null则为默认值application/octet-stream</param>
+            /// <param name="yourIsFile">是否把fileData当作文件路径处理</param>
+            /// <param 
name="yourFileData">文件内容或文件路径。为null则当作""(作为路径时如果路径不存在将会返回错误)</param>
+            public HttpMultipartDate(string yourName, string yourFileName, 
string yourContentType, bool yourIsFile, string yourFileData)
+            {
+                Name = yourName;
+                FileName = yourFileName;
+                ContentType = yourContentType;
+                IsFile = yourIsFile;
+                FileData = yourFileData;
+            }
+
+        }
+
+        public class HttpHelper
+        {
+            private delegate void SetHeadAttributeCallback(HttpWebRequest 
yourRequest, string yourHeadValue);
+
+            private static Dictionary<string, SetHeadAttributeCallback> 
dicHeadSetFun = new Dictionary<string, SetHeadAttributeCallback>();
+            static HttpHelper()
+            {
+                dicHeadSetFun.Add("Accept".ToUpper(), new 
SetHeadAttributeCallback((yourRequest, yourHeadValue) => yourRequest.Accept = 
yourHeadValue));
+                dicHeadSetFun.Add("Connection".ToUpper(), new 
SetHeadAttributeCallback((yourRequest, yourHeadValue) => { string tempHeadVaule 
= yourHeadValue.ToLower(); if (tempHeadVaule.IndexOf("keep-alive") != -1) { 
yourRequest.KeepAlive = true; } else if (tempHeadVaule.IndexOf("closee") != -1) 
{ yourRequest.KeepAlive = false; } else { yourRequest.Connection = 
yourHeadValue; } }));
+                dicHeadSetFun.Add("Date".ToUpper(), new 
SetHeadAttributeCallback((yourRequest, yourHeadValue) => { DateTime tempTime; 
if (!DateTime.TryParse(yourHeadValue, out tempTime)) tempTime = DateTime.Now; 
yourRequest.Date = tempTime; }));  //2009-05-01 14:57:32 
//修改该头需要4.0版本支持,如果升级4.0可以取消该注释,启用该功能
+                //dicHeadSetFun.Add("KeepAlive".ToUpper(), new 
SetHeadAttributeCallback((yourRequest, yourHeadValue) => yourRequest.KeepAlive 
= yourHeadValue));//该头可以直接使用Headers.Add
+                dicHeadSetFun.Add("Transfer-Encoding".ToUpper(), new 
SetHeadAttributeCallback((yourRequest, yourHeadValue) => 
yourRequest.TransferEncoding = yourHeadValue));
+                dicHeadSetFun.Add("Content-Length".ToUpper(), new 
SetHeadAttributeCallback((yourRequest, yourHeadValue) => { int tempLen; if 
(!int.TryParse(yourHeadValue, out tempLen)) tempLen = 0; 
yourRequest.ContentLength = tempLen; }));
+                dicHeadSetFun.Add("Content-Type".ToUpper(), new 
SetHeadAttributeCallback((yourRequest, yourHeadValue) => 
yourRequest.ContentType = yourHeadValue));
+                dicHeadSetFun.Add("Expect".ToUpper(), new 
SetHeadAttributeCallback((yourRequest, yourHeadValue) => yourRequest.Expect = 
yourHeadValue));
+                dicHeadSetFun.Add("Host".ToUpper(), new 
SetHeadAttributeCallback((yourRequest, yourHeadValue) => yourRequest.Host = 
yourHeadValue)); //修改该头需要4.0版本支持,如果升级4.0可以取消该注释,启用该功能
+                dicHeadSetFun.Add("IfModifiedSince".ToUpper(), new 
SetHeadAttributeCallback((yourRequest, yourHeadValue) => yourRequest.Referer = 
yourHeadValue));
+                dicHeadSetFun.Add("Referer".ToUpper(), new 
SetHeadAttributeCallback((yourRequest, yourHeadValue) => yourRequest.Referer = 
yourHeadValue));
+                dicHeadSetFun.Add("User-Agent".ToUpper(), new 
SetHeadAttributeCallback((yourRequest, yourHeadValue) => yourRequest.UserAgent 
= yourHeadValue));
+            }
+
+            /// <summary>
+            /// 添加http请求头属性(特殊属性自动转化为dicHeadSetFun中委托完成设置)
+            /// </summary>
+            /// <param name="httpWebRequest">HttpWebRequest</param>
+            /// <param name="heads">属性列表</param>
+            public static void AddHttpHeads(HttpWebRequest httpWebRequest, 
List<KeyValuePair<string, string>> heads)
+            {
+                if (httpWebRequest == null)
+                {
+                    return;
+                }
+                if (heads != null && heads.Count > 0)
+                {
+                    foreach (var Head in heads)
+                    {
+                        if (dicHeadSetFun.ContainsKey(Head.Key.ToUpper()))
+                        {
+                            
(dicHeadSetFun[Head.Key.ToUpper()])(httpWebRequest, Head.Value);
+                        }
+                        else
+                        {
+                            httpWebRequest.Headers.Add(Head.Key, Head.Value);
+                        }
+                    }
+                }
+            }
+
+
+
+            /// <summary>
+            /// 
添加http请求头属性(全部使用默认header.Add进行添加,失败后使用SetHeaderValue进行添加,不过依然可能失败)
+            /// </summary>
+            /// <param name="header">WebHeaderCollection</param>
+            /// <param name="heads">属性列表</param>
+            public static void AddHttpHeads(WebHeaderCollection header, 
List<KeyValuePair<string, string>> heads)
+            {
+                if (header == null)
+                {
+                    return;
+                }
+                if (heads != null)
+                {
+                    //wr.Headers.Add(new NameValueCollection());
+                    foreach (var Head in heads)
+                    {
+                        try
+                        {
+                            header.Add(Head.Key, Head.Value);
+                            
//((HttpWebRequest)wr).Headers.Add(HttpRequestHeader.Host, "www.contoso.com"); 
//必须用适当的属性修改host   使用4.0也报必须使用适当的属性或方法修改“Host”标头
+                            //((HttpWebRequest)wr).Headers.Add("Host", 
"192.168.0.1");//这样一样不行
+                            //SetHeaderValue(wr.Headers, "Host", 
"www.contoso.com:8080");//即使是4.0也无法直接修改
+                            //((HttpWebRequest)wr).Host = 
"www.contoso.com:8080";//只有这种方式在4.0可以生效
+                        }
+                        catch (Exception ex)
+                        {
+                            SetHeaderValue(header, Head.Key, Head.Value);
+                            MyHttp.GetError(ex);
+                        }
+                    }
+                }
+            }
+
+            /// <summary>
+            /// 设置请求头(注意该方法未经过测试,使用前请先测试)
+            /// </summary>
+            /// <param name="header">WebHeaderCollection</param>
+            /// <param name="name">key</param>
+            /// <param name="value">value</param>
+            public static void SetHeaderValue(WebHeaderCollection header, 
string name, string value)
+            {
+                var property = 
typeof(WebHeaderCollection).GetProperty("InnerCollection", 
System.Reflection.BindingFlags.Instance | 
System.Reflection.BindingFlags.NonPublic);
+                if (property != null)
+                {
+                    var collection = property.GetValue(header, null) as 
NameValueCollection;
+                    collection[name] = value;
+                }
+            }
+        }
+
+        public class HttpTimeLine
+        {
+            /// <summary>
+            /// 开始时间
+            /// </summary>
+            public DateTime StartTime { get; set; }
+
+            /// <summary>
+            /// 耗时(毫秒为单位)
+            /// </summary>
+            public long ElapsedTime { get; set; }
+
+            public HttpTimeLine()
+            {
+                ElapsedTime = 0;
+            }
+        }
+
+        /// <summary>
+        /// 使用前请先查看ErrorMes是否有错误信息
+        /// </summary>
+        public class MyHttpResponse
+        {
+            private int statusCode = -99;
+            private string responseLine = null;
+            private string responseBody = null;
+            private string responseRaw = null;
+            private string errorMes = null;
+            public HttpTimeLine TimeLine { get; internal set; }
+            public HttpWebResponse HttpResponse { get; internal set; }
+            public string ErrorMes
+            {
+                get { return errorMes; }
+                internal set { errorMes = value; responseBody = value; }
+            }
+
+            public MyHttpResponse()
+            {
+                TimeLine = null;
+                HttpResponse = null;
+            }
+
+            public int StatusCode
+            {
+                get
+                {
+                    if (HttpResponse == null)
+                    {
+                        return 0;
+                    }
+                    if (statusCode == -99)
+                    {
+                        statusCode = (int)HttpResponse.StatusCode;
+                    }
+                    return statusCode;
+                }
+            }
+
+            public string ResponseLine
+            {
+                get
+                {
+                    if (responseLine == null && HttpResponse != null)
+                    {
+                        responseLine = string.Format(@"HTTP/{0} {1} {2}",
+                            HttpResponse.ProtocolVersion == null ? "NULL" : 
HttpResponse.ProtocolVersion.ToString(),
+                            StatusCode,
+                            HttpResponse.StatusCode == null ? "NULL" : 
HttpResponse.StatusCode.ToString());
+                    }
+                    return responseLine;
+                }
+            }
+
+            public WebHeaderCollection ResponseHeads
+            {
+                get
+                {
+                    if (HttpResponse == null)
+                    {
+                        return null;
+                    }
+                    return HttpResponse.Headers;
+                }
+            }
+
+            /// <summary>
+            /// 获取Response Body(如果返回null则表示请求未发起,错误原因通过ErrorMes查看)
+            /// </summary>
+            public string ResponseBody
+            {
+                get
+                {
+                    if (responseBody == null && HttpResponse != null)
+                    {
+                        SeekResponseStream();
+                    }
+                    return responseBody;
+                }
+            }
+
+            /// <summary>
+            /// 获取Response Raw格式的报文(如果返回null则表示请求未发起,错误原因通过ErrorMes查看)
+            /// </summary>
+            public string ResponseRaw
+            {
+                get
+                {
+                    if (errorMes != null)
+                    {
+                        return null;
+                    }
+                    if (responseRaw == null && HttpResponse != null)
+                    {
+                        responseRaw = string.Format("{0}\r\n{1}{2}", 
ResponseLine ?? "NULL", ResponseHeads.ToString(), ResponseBody ?? "NULL");
+                    }
+                    return responseRaw;
+                }
+            }
+
+            internal void SavaData(string saveFileName)
+            {
+                Stream receiveStream = null;
+                try
+                {
+                    using (FileStream stream = new FileStream(saveFileName, 
FileMode.Create, FileAccess.Write, FileShare.Write))
+                    {
+                        receiveStream = HttpResponse.GetResponseStream();
+                        int tempReadCount = 1024;
+                        byte[] infbytes = new byte[tempReadCount]; 
//反复使用前也不要清空,因为后面写入会指定有效长度
+                        int tempLen = tempReadCount;
+                        int offset = 0;
+                        while (tempLen >= tempReadCount)
+                        {
+                            tempLen = receiveStream.Read(infbytes, 0, 
tempReadCount);
+                            stream.Write(infbytes, 0, tempLen);//FileStream 
内建缓冲区,不用自己构建缓存写入,FileStream的offset会自动维护,也可以使用stream.Position强制指定
+                            offset += tempLen;
+                        }
+                        responseBody = string.Format("file save success in [ 
{0} ]  with {1}byte", saveFileName, offset);
+                    }
+                    #region WriteAllBytes
+                    /*
+                    byte[] infbytes = new byte[10240];
+                    int tempLen = 512;
+                    int offset = 0;
+
+                    //数据最多20k可以不需要分段读取
+                    while (tempLen - 512 >= 0)
+                    {
+                    tempLen = ReceiveStream.Read(infbytes, offset, 512);
+                    offset += tempLen;
+                    }
+                    byte[] bytesToSave = new byte[offset];
+                    for (int i = 0; i < offset; i++)
+                    {
+                    bytesToSave[i] = infbytes[i];
+                    }
+                    File.WriteAllBytes(saveFileName, bytesToSave);
+                    */
+                    #endregion
+                }
+                catch (Exception ex)
+                {
+                    responseBody = string.Format("file save fail with [ {0} ]  
", ex.Message);
+                }
+                finally
+                {
+                    if (receiveStream != null)
+                    {
+                        receiveStream.Close();
+                    }
+                }
+            }
+
+            internal void SeekResponseStream()
+            {
+                if (HttpResponse != null && responseBody == null)
+                {
+                    Stream receiveStream = HttpResponse.GetResponseStream();
+                    Encoding nowEncoding;
+                    try
+                    {
+                        nowEncoding = 
string.IsNullOrEmpty(HttpResponse.CharacterSet) ? Encoding.UTF8 : 
Encoding.GetEncoding(HttpResponse.CharacterSet);
+                    }
+                    catch
+                    {
+                        nowEncoding = Encoding.UTF8;
+                    }
+                    try
+                    {
+                        using (var responseStreamReader = new 
StreamReader(receiveStream, nowEncoding))  //will close the HttpResponse Stream
+                        {
+                            responseBody = responseStreamReader.ReadToEnd();
+                        }
+                    }
+                    catch (Exception ex)
+                    {
+                        responseBody = ex.Message;
+                    }
+                    #region Read
+                    //使用如下方法自己读取byte[] 是可行的,不过在Encoding 
可变编码方式时,不能确保分段不被截断,直接使用内置StreamReader也是可以的
+                    /*
+                    Byte[] read = new Byte[512];
+                    int bytes = receiveStream.Read(read, 0, 512);
+                    if (showResponseHeads)
+                    {
+                        re = result.Headers.ToString();
+                    }
+                    while (bytes > 0)
+                    {
+                        re += responseEncoding.GetString(read, 0, bytes);
+                        bytes = receiveStream.Read(read, 0, 512);
+                    }
+                     * */
+                    #endregion
+                }
+            }
+        }
+
+        public class MyHttp
+        {
+            private int httpTimeOut = 100000;                                  
             //http time out ,SendData and HttpPostData will use this value   
(连接超时)
+            private int httpReadWriteTimeout = 300000;                         
             //WebRequest.ReadWriteTimeout  [未使用]          (读取/写入超时)
+            private string defaultContentType = null;                          
             //请求默认ContentType  (Content-Type: text/plain; charset=utf-8)
+            private bool withDefaultCookieContainer = false;                   
             //是否默认启用CookieContainer,如果启用则默认会管理所有使用MyHttp的cookie内容
+            private bool recordRequestTimeLine = true;                         
             //是否记录请求时间线
+            private readonly string EOF = "\r\n";
+            private CookieContainer cookieContainer;
+            private List<KeyValuePair<string, string>> requestDefaultHeads;
+
+
+            public Encoding RequestEncoding { get; set; }  //需要发送数据,将使用此编码   
[未使用]
+            public Encoding ResponseEncoding { get; set; } 
//如果要显示返回数据,返回数据将使用此编码  [未使用]
+
+            /// <summary>
+            /// get or set HttpTimeOut
+            /// </summary>
+            public int HttpTimeOut
+            {
+                get { return httpTimeOut; }
+                set { httpTimeOut = value; }
+            }
+
+            /// <summary>
+            /// get or set default ContentType
+            /// </summary>
+            public string DefaultContentType
+            {
+                get { return defaultContentType; }
+                set { defaultContentType = value; }
+            }
+
+            /// <summary>
+            /// get is record RequestTimeLine
+            /// </summary>
+            public bool IsrecordRequestTimeLine
+            {
+                get { return recordRequestTimeLine; }
+            }
+
+            /// <summary>
+            /// get or set is use DefaultCookieContainer
+            /// </summary>
+            public bool IsWithDefaultCookieContainer
+            {
+                get { return withDefaultCookieContainer; }
+                set { withDefaultCookieContainer = value; }
+            }
+
+            /// <summary>
+            /// get Inner CookieContainer
+            /// </summary>
+            public CookieContainer InnerCookieContainer
+            {
+                get { return cookieContainer; }
+            }
+
+            /// <summary>
+            /// get default request heads
+            /// </summary>
+            public List<KeyValuePair<string, string>> RequestDefaultHeads
+            {
+                get { return requestDefaultHeads; }
+            }
+
+            static MyHttp()
+            {
+                //ServicePointManager.ServerCertificateValidationCallback = 
new System.Net.Security.RemoteCertificateValidationCallback(
+                //    (sender, certificate, chain, sslPolicyErrors) => { 
return true; });
+                ServicePointManager.ServerCertificateValidationCallback = 
MyRemoteCertificateValidationCallback;

Review Comment:
   已按项目所有者最新要求在 c95ae8a 删除整个未使用的 NetService/MyWebTool.cs(含全部嵌套类型),该进程级 TLS 
回调副作用不再随库分发。全仓源码不再包含 ServicePointManager / 证书校验回调设置,程序集回归测试也确认旧 HTTP 类型不存在。309 
项测试通过;保留了 DubboNet 正在使用的 HTTP/Triple/Telnet 实现。



##########
MyCommonHelper/EncryptionHelper/MyRC4.cs:
##########
@@ -0,0 +1,84 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace MyCommonHelper.EncryptionHelper
+{
+    public class MyRC4

Review Comment:
   已在 c95ae8a 
清理:删除全部七个未使用的加密工具文件(AES/DES/TripleDES/RC4/RSA/Encryption/XOR),仅保留一致性路由实际使用的 
MyHash/MurmurHash2。也删除了无引用的 CommonLog、MyCommonTool、通用扩展与旧 HTTP / 
EsTelnet。新增程序集类型检查,确保这些类型不在新库中。公开历史工具 API 的兼容性变化已在 PR 与 
Docs/ImportReviewStatus.md 明确记录。



##########
NetService/MyWebTool.cs:
##########
@@ -0,0 +1,1106 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Diagnostics;
+using System.Net;
+using System.IO;
+using System.Collections.Specialized;
+using System.Linq;
+using System.Security.Cryptography.X509Certificates;
+
+
+/*******************************************************************************
+* Copyright (c) 2015 lijie

Review Comment:
   
本轮按所有者的明确要求删除无用历史工具:五个被点名文件中,MyWebTool.cs、EsTelnet.cs、MyEncryption.cs、MyExtensionMethods.cs
 已从当前源码树移除;仅 ExTelnet.cs 仍由 
DubboActuator/元数据路径和测试实际使用,因此保留其原始来源/版权声明。本条继续开放,不能因为删除四个文件就宣称完成授权;原提交历史仍完整保留,SGA/ICLA/历史覆盖范围也仍待确认。



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to