PureBasic Forum
http://forums.purebasic.com/english/

HTTPProxy() + async HTTPRequest() error
http://forums.purebasic.com/english/viewtopic.php?f=13&t=74886
Page 1 of 1

Author:  zikitrake [ Tue Mar 17, 2020 10:12 am ]
Post subject:  HTTPProxy() + async HTTPRequest() error

Hello :D

This code fails randomly when I activate HTTPProxy() with a
Quote:
the debugged executable quit unexpectedly


(if I deactivate it it is executed correctly)

PB 5.71 LTS x64, Windows 10 x64
Code:
InitNetwork()

Repeat
 
  If status = 0
    HTTPProxy("http://159.203.45.27:8080")
   
    HttpRequest = HTTPRequest(#PB_HTTP_Get, "https://www.google.com", "", #PB_HTTP_Asynchronous)
    If HttpRequest
      status = 1
      Debug "started"
    EndIf
  EndIf
 
  If status = 1
    Progress = HTTPProgress(HttpRequest)
    Delay(1000)
   
    If progress
      Debug Progress
    Else
      FinishHTTP(HTTPRequest)
      status = 0
    EndIf
   
    If status And Progress = #PB_HTTP_Success Or Progress = #PB_HTTP_Failed Or Progress = #PB_HTTP_Aborted
     
      If Progress = #PB_HTTP_Success
        *Buffer = HTTPMemory(HTTPRequest)
        Debug PeekS(*Buffer, MemorySize(*Buffer), #PB_UTF8|#PB_ByteLength)
        FreeMemory(*Buffer)
      EndIf
     
      FinishHTTP(HTTPRequest)
      status = 0
      Debug "finished"
    EndIf
  EndIf
 Delay(1000)
ForEver



PS: I know that proxy is currently google-banned, but that's another story :)

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/