Skip to content

Commit

Permalink
書き込みエラー時ヘッダ出力とりあえず実装 #6
Browse files Browse the repository at this point in the history
  • Loading branch information
onihusube committed May 7, 2022
1 parent 123c42e commit 76bd305
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion 2chAPIProxy/DatProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1348,8 +1348,10 @@ private void ResPostv2(Session oSession, bool is2ch)
// 5秒待機する
Thread.Sleep(5000);
}
if (wres.Headers.AllKeys.Contains("X-Chx-Error") == true)
else if (wres.Headers.AllKeys.Contains("X-Chx-Error") == true)
{
// Monakeyが送られてきておらず、X-Chx-Errorヘッダがセットされている場合、なんかエラー

ViewModel.OnModelNotice("X-Chx-Error : " + wres.Headers["X-Chx-Error"]);

// E3000番台のエラーが帰ってきたらMonaKeyを更新する(雑な暫定対応
Expand All @@ -1358,6 +1360,18 @@ private void ResPostv2(Session oSession, bool is2ch)
ResetMonakey();
}

string header_log = "リクエストヘッダ\n";
foreach (var header in Write.Headers.AllKeys)
{
header_log += $"{header}:{Write.Headers[header].ToString()}";
}

header_log += "\nレスポンスヘッダ\n";
foreach (var header in wres.Headers.AllKeys)
{
header_log += $"{header}:{wres.Headers[header].ToString()}";
}
ViewModel.OnModelNotice(header_log);
}

using (System.IO.StreamReader Res = new System.IO.StreamReader(wres.GetResponseStream(), Encoding.GetEncoding("Shift_JIS")))
Expand Down

0 comments on commit 76bd305

Please sign in to comment.