Skip to content

Commit

Permalink
3.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
rusildo committed Sep 12, 2015
1 parent 66ece84 commit 3991bc0
Show file tree
Hide file tree
Showing 12 changed files with 242 additions and 226 deletions.
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
// Можно задать все значения или принять номер построения и номер редакции по умолчанию,
// используя "*", как показано ниже:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.3.0.0")]
[assembly: AssemblyFileVersion("3.3.0.0")]
[assembly: AssemblyVersion("3.3.1.0")]
[assembly: AssemblyFileVersion("3.3.1.0")]
[assembly: NeutralResourcesLanguageAttribute("ru")]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ xNet - a class library for .NET Framework which includes:
* Classes for work with proxy servers: _HTTP, Socks4(a), Socks5, Chain_.
* Classes for work with *HTTP 1.0/1.1* protocol: _keep-alive, gzip, deflate, chunked, SSL, proxies and more_.

Подробное описание на русском: http://habrahabr.ru/post/146475/
Подробное описание на русском: http://habrahabr.ru/post/146475/ <br />
Если вы хотите поблагодарить автора: R284554004163 (WebMoney)

Example:
Expand Down Expand Up @@ -38,4 +38,4 @@ using (var request = new HttpRequest("http://site.com/"))
// But in this request they will be gone.
request.Post("/").None();
}
</pre>
</pre>
15 changes: 2 additions & 13 deletions xNet/NetException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ namespace xNet
/// <summary>
/// Исключение, которое выбрасывается, в случае возникновения ошибки при работе с сетью.
/// </summary>
public class NetException : Exception, ISerializable
[Serializable]
public class NetException : Exception
{
#region Конструкторы (открытые)

Expand All @@ -34,17 +35,5 @@ public NetException(string message, Exception innerException = null)
/// <param name="streamingContext">Экземпляр класса <see cref="StreamingContext"/>, содержащий источник сериализованного потока, связанного с новым экземпляром класса <see cref="NetException"/>.</param>
protected NetException(SerializationInfo serializationInfo, StreamingContext streamingContext)
: base(serializationInfo, streamingContext) { }


/// <summary>
/// Заполняет экземпляр <see cref="SerializationInfo"/> данными, необходимыми для сериализации исключения <see cref="NetException"/>.
/// </summary>
/// <param name="serializationInfo">Данные о сериализации, <see cref="SerializationInfo"/>, которые должны использоваться.</param>
/// <param name="streamingContext">Данные о сериализации, <see cref="StreamingContext"/>, которые должны использоваться.</param>
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
public override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext)
{
base.GetObjectData(serializationInfo, streamingContext);
}
}
}
26 changes: 17 additions & 9 deletions xNet/~Http/Http.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,16 @@ public static class Http

#region Статические поля (закрытые)

[ThreadStatic]
private static readonly Random _rand = new Random();
[ThreadStatic] private static Random _rand;
private static Random Rand
{
get
{
if (_rand == null)
_rand = new Random();
return _rand;
}
}

#endregion

Expand Down Expand Up @@ -341,7 +349,7 @@ public static string IEUserAgent()
}
else
{
switch (_rand.Next(3))
switch (Rand.Next(3))
{
case 0:
version = "10.0";
Expand Down Expand Up @@ -383,7 +391,7 @@ public static string OperaUserAgent()

#region Генерация случайной версии

switch (_rand.Next(4))
switch (Rand.Next(4))
{
case 0:
version = "12.16";
Expand Down Expand Up @@ -424,7 +432,7 @@ public static string ChromeUserAgent()

#region Генерация случайной версии

switch (_rand.Next(5))
switch (Rand.Next(5))
{
case 0:
version = "41.0.2228.0";
Expand Down Expand Up @@ -470,7 +478,7 @@ public static string FirefoxUserAgent()

#region Генерация случайной версии

switch (_rand.Next(5))
switch (Rand.Next(5))
{
case 0:
version = "36.0";
Expand Down Expand Up @@ -518,7 +526,7 @@ public static string OperaMiniUserAgent()

#region Генерация случайной версии

switch (_rand.Next(3))
switch (Rand.Next(3))
{
case 0:
os = "iOS";
Expand Down Expand Up @@ -602,7 +610,7 @@ private static string RandomWindowsVersion()
{
string windowsVersion = "Windows NT ";

switch (_rand.Next(4))
switch (Rand.Next(4))
{
case 0:
windowsVersion += "5.1"; // Windows XP
Expand All @@ -621,7 +629,7 @@ private static string RandomWindowsVersion()
break;
}

if (_rand.NextDouble() < 0.2)
if (Rand.NextDouble() < 0.2)
{
windowsVersion += "; WOW64"; // 64-битная версия.
}
Expand Down
18 changes: 16 additions & 2 deletions xNet/~Http/HttpException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ namespace xNet
/// <summary>
/// Исключение, которое выбрасывается, в случае возникновения ошибки при работе с HTTP-протоколом.
/// </summary>
public sealed class HttpException : NetException, ISerializable
[Serializable]
public sealed class HttpException : NetException
{
#region Свойства (открытые)

Expand Down Expand Up @@ -65,7 +66,14 @@ public HttpException(string message, HttpExceptionStatus status,
/// <param name="serializationInfo">Экземпляр класса <see cref="SerializationInfo"/>, который содержит сведения, требуемые для сериализации нового экземпляра класса <see cref="HttpException"/>.</param>
/// <param name="streamingContext">Экземпляр класса <see cref="StreamingContext"/>, содержащий источник сериализованного потока, связанного с новым экземпляром класса <see cref="HttpException"/>.</param>
protected HttpException(SerializationInfo serializationInfo, StreamingContext streamingContext)
: base(serializationInfo, streamingContext) { }
: base(serializationInfo, streamingContext)
{
if (serializationInfo != null)
{
Status = (HttpExceptionStatus)serializationInfo.GetInt32("Status");
HttpStatusCode = (HttpStatusCode)serializationInfo.GetInt32("HttpStatusCode");
}
}


/// <summary>
Expand All @@ -77,6 +85,12 @@ protected HttpException(SerializationInfo serializationInfo, StreamingContext st
public override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext)
{
base.GetObjectData(serializationInfo, streamingContext);

if (serializationInfo != null)
{
serializationInfo.AddValue("Status", (int)Status);
serializationInfo.AddValue("HttpStatusCode", (int)HttpStatusCode);
}
}
}
}
20 changes: 14 additions & 6 deletions xNet/~Http/~Content/MultipartContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,16 @@ public bool IsFieldFile()

#region Статические поля (закрытые)

[ThreadStatic]
private static readonly Random _rand = new Random();
[ThreadStatic] private static Random _rand;
private static Random Rand
{
get
{
if (_rand == null)
_rand = new Random();
return _rand;
}
}

#endregion

Expand Down Expand Up @@ -397,18 +405,18 @@ public static string GetRandomString(int length)

for (int i = 0; i < length; ++i)
{
switch (_rand.Next(3))
switch (Rand.Next(3))
{
case 0:
strBuilder.Append((char)_rand.Next(48, 58));
strBuilder.Append((char)Rand.Next(48, 58));
break;

case 1:
strBuilder.Append((char)_rand.Next(97, 123));
strBuilder.Append((char)Rand.Next(97, 123));
break;

case 2:
strBuilder.Append((char)_rand.Next(65, 91));
strBuilder.Append((char)Rand.Next(65, 91));
break;
}
}
Expand Down
14 changes: 11 additions & 3 deletions xNet/~Proxy/ChainProxyClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@ public class ChainProxyClient : ProxyClient
{
#region Статические поля (закрытые)

[ThreadStatic]
private static readonly Random _rand = new Random();
[ThreadStatic] private static Random _rand;
private static Random Rand
{
get
{
if (_rand == null)
_rand = new Random();
return _rand;
}
}

#endregion

Expand Down Expand Up @@ -203,7 +211,7 @@ public override TcpClient CreateConnection(string destinationHost, int destinati
// Перемешиваем прокси.
for (int i = 0; i < proxies.Count; i++)
{
int randI = _rand.Next(proxies.Count);
int randI = Rand.Next(proxies.Count);

ProxyClient proxy = proxies[i];
proxies[i] = proxies[randI];
Expand Down
Loading

0 comments on commit 3991bc0

Please sign in to comment.