Skip to content

Commit

Permalink
どんぐり枯れループを回避するように修正
Browse files Browse the repository at this point in the history
  • Loading branch information
onihusube committed Apr 15, 2024
1 parent bf06e21 commit 9421099
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
28 changes: 15 additions & 13 deletions 2chAPIProxy/DatProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -905,21 +905,16 @@ private void ResPost(Session oSession, bool is2ch)

//送信クッキーのセット
String domain = CheckWriteuri.Match(oSession.fullUrl).Groups[1].Value;
//String domain = ".5ch.net";
foreach (var cook in Cookie)
foreach (var cook in Cookie.Where(c => string.IsNullOrEmpty(c.Value) == false))
{
if (cook.Value != "")
var m = Regex.Match(cook.Value, @"^(.+?)=(.*?)(;|$)");
try
{
var m = Regex.Match(cook.Value, @"^(.+?)=(.*?)(;|$)");
try
{
Write.CookieContainer.Add(new Cookie(m.Groups[1].Value, m.Groups[2].Value, "/", domain));
}
catch (CookieException)
{
continue;
}
//if (cook.Key == "PREN" || cook.Key == "yuki" || cook.Key == "MDMD" || cook.Key == "DMDM")
Write.CookieContainer.Add(new Cookie(m.Groups[1].Value, m.Groups[2].Value, "/", domain));
}
catch (CookieException)
{
continue;
}
}
//浪人を無効化
Expand Down Expand Up @@ -970,6 +965,13 @@ private void ResPost(Session oSession, bool is2ch)

if (wres.Headers.AllKeys.Contains("X-Chx-Error") == true)
{
// どんぐりが枯れてしまいました。
// X-Chx-Error:1930 Acorn have dried up.
if (wres.Headers["X-Chx-Error"].Contains("1930"))
{
// どんぐり枯れを検知したら、acornクッキーを削除する
Cookie["acorn"] = "";
}
ViewModel.OnModelNotice("X-Chx-Error : " + wres.Headers["X-Chx-Error"]);
}

Expand Down
2 changes: 1 addition & 1 deletion 2chAPIProxy/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:_2chAPIProxy" mc:Ignorable="d" x:Class="_2chAPIProxy.MainWindow"
Title="2chAPIProxy Ver:2023.07.19 nonAPI test" Height="480" Width="640"
Title="2chAPIProxy Ver:2024.04.16 nonAPI test" Height="480" Width="640"
Icon="icon3.ico" WindowStartupLocation="CenterScreen" ResizeMode="CanMinimize" Background="White" d:DataContext="{d:DesignInstance {x:Type local:ViewModel}}">
<Window.InputBindings>
<KeyBinding Gesture="Ctrl+S" Command="{Binding SaveSetting}"/>
Expand Down

0 comments on commit 9421099

Please sign in to comment.