summaryrefslogtreecommitdiff
path: root/plugins/Watrack
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-01-04 13:38:02 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-01-04 13:38:02 +0300
commit94667140aeb3886d22e4c1301423fe99aaf3fba4 (patch)
tree88bc46dfa6a3dba117905f7994b5e5f6ae09fa2a /plugins/Watrack
parente63471b9885d040b9e6db3255432f6cea36144e9 (diff)
Netlib: pascal code is completely isolated from C++ core using helpers
Diffstat (limited to 'plugins/Watrack')
-rw-r--r--plugins/Watrack/myshows/i_cookies.inc51
-rw-r--r--plugins/Watrack/myshows/i_myshows_api.inc1
2 files changed, 10 insertions, 42 deletions
diff --git a/plugins/Watrack/myshows/i_cookies.inc b/plugins/Watrack/myshows/i_cookies.inc
index cd01ef6621..82c12f3b3d 100644
--- a/plugins/Watrack/myshows/i_cookies.inc
+++ b/plugins/Watrack/myshows/i_cookies.inc
@@ -2,46 +2,14 @@
const
cookies:pAnsiChar=nil;
-function ExtractCookies(resp:PNETLIBHTTPREQUEST):integer;
-var
- cnt,len:integer;
- p,pc:pAnsiChar;
-begin
- result:=0;
-
- mFreeMem(cookies);
- mGetMem(cookies,1024);
-
- pc:=cookies;
- for cnt:=0 to resp^.headersCount-1 do
- begin
- with resp^.headers[cnt] do
- if StrCmp(szName,'Set-Cookie')=0 then
- begin
- len:=0;
- p:=szValue;
- while (p^<>#0) and (p^<>';') do
- begin
- inc(p);
- inc(len);
- end;
- if pc<>cookies then
- begin
- pc^:=';'; inc(pc);
- pc^:=' '; inc(pc);
- end;
- pc:=StrCopyE(pc,szValue,len);
- inc(result);
- end;
- end;
-end;
-
function SendRequestCookies(url:PAnsiChar;useCookies:boolean):pAnsiChar;
var
nlu:TNETLIBUSER;
req :TNETLIBHTTPREQUEST;
- resp:PNETLIBHTTPREQUEST;
+ resp:THANDLE;
hTmpNetLib:THANDLE;
+ bufLen:int;
+ pBuf:PAnsiChar;
nlh:array [0..10] of TNETLIBHTTPHEADER;
begin
result:=nil;
@@ -66,20 +34,21 @@ begin
hTmpNetLib:=Netlib_RegisterUser(@nlu);
resp:=Netlib_HttpTransaction(hTmpNetLib,@req);
- if resp<>nil then
+ if resp<>0 then
begin
- if resp^.resultCode=200 then
+ if Netlib_HttpResult(resp)=200 then
begin
- if resp.pData<>nil then
- StrDup(result,resp.pData,resp.dataLength)
+ pBuf := Netlib_HttpBuffer(resp,bufLen);
+ if pBuf<>nil then
+ StrDup(result,pBuf,bufLen)
else
result:=PAnsiChar(200);
if not useCookies then
- ExtractCookies(resp);
+ cookies := Netlib_HttpCookies(resp);
end
else
begin
- result:=pAnsiChar(int_ptr(resp^.resultCode and $0FFF));
+ result:=pAnsiChar(int_ptr(Netlib_HttpResult(resp) and $0FFF));
end;
Netlib_FreeHttpRequest(resp);
end;
diff --git a/plugins/Watrack/myshows/i_myshows_api.inc b/plugins/Watrack/myshows/i_myshows_api.inc
index f92df86b50..828fb5c650 100644
--- a/plugins/Watrack/myshows/i_myshows_api.inc
+++ b/plugins/Watrack/myshows/i_myshows_api.inc
@@ -88,7 +88,6 @@ begin
StrReplace(request,'<password>',buf);
res:=SendRequestCookies(request,false);
-// res:=SendRequest(request,REQUEST_GET);
if res<>nil then
begin
if uint_ptr(res)<$0FFF then