@@ -40,7 +40,6 @@ public sealed class EHentaiEngine : WebSearchEngine, ILoginEngine, INotifyProper
4040 } ;
4141
4242 private string m_password ;
43-
4443 private string m_username ;
4544
4645 #region Url
@@ -52,7 +51,7 @@ public sealed class EHentaiEngine : WebSearchEngine, ILoginEngine, INotifyProper
5251
5352 private static readonly Url ExHentai_Image_Lookup = Url . Combine ( EXHENTAI_URI , "upld" , "image_lookup.php" ) ;
5453
55- private Url Base
54+ public override Url BaseUrl
5655 {
5756 get { return IsLoggedIn ? EXHENTAI_URI : EHENTAI_URI ; }
5857 }
@@ -86,6 +85,7 @@ public EHentaiEngine() : base(EHENTAI_URI)
8685 m_client = new HttpClient ( m_clientHandler ) ;
8786 Cookies = new CookieJar ( ) ;
8887 IsLoggedIn = false ;
88+
8989 }
9090
9191 /*
@@ -103,8 +103,11 @@ protected override async Task<IDocument> GetDocumentAsync(object origin, SearchQ
103103 {
104104 const string name = "a.jpg" ;
105105
106- string t = await query . GetFilePathOrTemp ( name ) ;
106+ ( string t , bool b ) = await query . GetFilePathOrTemp ( name ) ;
107107
108+ if ( b ) {
109+ Trace . WriteLine ( $ "allocated { t } ", nameof ( GetDocumentAsync ) ) ;
110+ }
108111 var data = new MultipartFormDataContent ( )
109112 {
110113 { new FileContent ( t ) , "sfile" , name } ,
@@ -146,6 +149,7 @@ protected override async Task<IDocument> GetDocumentAsync(object origin, SearchQ
146149 m_clientHandler . CookieContainer . Add ( new Cookie ( c . Name , c . Value , c . Path , c . Domain ) ) ;
147150 }
148151
152+ Debug . WriteLine ( $ "{ Lookup } ", nameof ( GetDocumentAsync ) ) ;
149153 var req = new HttpRequestMessage ( HttpMethod . Post , Lookup )
150154 {
151155 Content = data ,
@@ -170,7 +174,7 @@ protected override async Task<IDocument> GetDocumentAsync(object origin, SearchQ
170174
171175 private async Task < IFlurlResponse > GetSessionAsync ( )
172176 {
173- return await Base . WithCookies ( Cookies )
177+ return await EXHENTAI_URI . WithCookies ( Cookies )
174178 . WithHeaders ( new
175179 {
176180 User_Agent = HttpUtilities . UserAgent
@@ -285,7 +289,13 @@ private static EhResult GetEhResult(INode n)
285289 // ReSharper restore InconsistentNaming
286290 }
287291
288- public override void Dispose ( ) { }
292+ public override void Dispose ( )
293+ {
294+ m_client . Dispose ( ) ;
295+ m_clientHandler . Dispose ( ) ;
296+ Cookies . Clear ( ) ;
297+ IsLoggedIn = false ;
298+ }
289299
290300 public string Username
291301 {
@@ -348,11 +358,11 @@ public async Task<bool> LoginAsync()
348358 }
349359
350360 var res2 = await GetSessionAsync ( ) ;
351- BaseUrl = Base ;
361+
352362 return IsLoggedIn = res2 . ResponseMessage . IsSuccessStatusCode ;
353363 }
354364
355- #region
365+ #region
356366
357367 private void OnPropertyChanged ( [ CallerMemberName ] string propertyName = null )
358368 {
0 commit comments