Page 3 of 3

Re: HTTPGetFromWeb() 2.0 - use WinInet API

Posted: Fri Feb 01, 2013 8:36 pm
by luis
Try to look as this for the two concurrent download limits -> http://support.microsoft.com/kb/282402, if I remember correctly (now I don't have time to check) the APIs used here obey to the same settings.

Killing a thread should always be avoided, the implemented callbacks can force a thread to end gracefully as shown in the demo program when you click on the abort button.

BTW there are other routines similar to this one and cross platform too, don't know if they do all the things this does but try to do a search in the forum if interested.

Re: HTTPGetFromWeb() 2.0 - use WinInet API

Posted: Fri Feb 01, 2013 9:36 pm
by PureGuy
luis wrote:Try to look as this for the two concurrent download limits -> http://support.microsoft.com/kb/282402, if I remember correctly (now I don't have time to check) the APIs used here obey to the same settings.
That was the limit, after adding these values, all 3 work simultaneously :D
luis wrote: Killing a thread should always be avoided, the implemented callbacks can force a thread to end gracefully as shown in the demo program when you click on the abort button.
Well, before where i aborted the 2 running ones, the 3rd never starts.
Also the aborting message is ignored in this case, so the threat just stays alive.

Re: HTTPGetFromWeb() 2.0 - use WinInet API

Posted: Tue Dec 16, 2014 8:59 pm
by pasmo
hello guyz, can you help me please if it possible ( :

i was windering of adding a cookies support in your function.. in 3.0 version...
but... i can't...

so i add a cookie string to structure description

Code: Select all

sCookie.s           ; Cookie string
and write some cookie condition before HttpSendRequest_ like this

Code: Select all

  If *tHTTP\lSecureSocket
    ;
    ; *******************************************************************************************
    ; Common error anticipation/correction
    ; Often unnecessary but should be included for best reliability
    dwBuffLen = SizeOf(dwFlags)
    InternetQueryOption_(hReq, #INTERNET_OPTION_SECURITY_FLAGS, @dwFlags, @dwBuffLen)
    dwFlags | #SECURITY_FLAG_IGNORE_CERT_CN_INVALID | #SECURITY_FLAG_IGNORE_CERT_DATE_INVALID | #SECURITY_FLAG_IGNORE_REVOCATION | #SECURITY_FLAG_IGNORE_UNKNOWN_CA | #SECURITY_FLAG_IGNORE_WRONG_USAGE
    InternetSetOption_(hReq, #INTERNET_OPTION_SECURITY_FLAGS, @dwFlags, dwBuffLen)
    ; *******************************************************************************************
    ;
  EndIf
  
  ;
  ; HERE IS MY COOKIE CONDITION
  ;
  If *tHTTP\sCookie
    *tHTTP\sCookie = "Cookie: " + *tHTTP\sCookie + Chr(13) + Chr(10)
    HttpAddRequestHeaders_(hReq, *tHTTP\sCookie, Len(*tHTTP\sCookie), $80000000|$20000000)
  EndIf
  
  
  
  Repeat
    ; *** Send Request ***
   
    If Not HttpSendRequest_(hReq, @*tHTTP\sHeaderData, *tHTTP\lHeaderDataLen, @*tHTTP\sOptionalData, *tHTTP\lOptionalDataLen)
      lIntRetVal = #PBL_ERR_INTERNET_HTTP_SEND
      Break
    EndIf
after that i initialize request structure like this

Code: Select all

IncludeFile #PB_Compiler_FilePath + "..\HTTPGetFromWeb30.pb"

Define tHTTP.T_PBL_HTTP_GET_FROM_WEB

tHTTP\lThreadID = 0
tHTTP\sCookie = "_ddn_intercept_2_=8f88db2768dfb1b102597762bdc9c81f"
tHTTP\sURL = "http://rutor.org"   
tHTTP\lDestination = #PBL_WRITE_TO_MEMORY
HTTPGetFromWeb (@tHTTP)


Debug PeekS(tHTTP\DestBuffer,tHTTP\lTotBytesRead,#PB_UTF8)
and a result says that cookie isn't setted... the site don't gives what he have.. but in a "badpageresult" we see a correct cookie (eg. "_ddn_intercept_2_=8f88db2768dfb1b102597762bdc9c81f") which if setted site gives a full http code

i think these some kind if setted flags problem... i try to change flags in

Code: Select all

 If *tHTTP\lFlags = 0 ; if flags not specified
    ; no popup for cookies + load from Internet (not cache)
    *tHTTP\lFlags = #INTERNET_FLAG_NO_UI | #INTERNET_FLAG_NO_CACHE_WRITE | #INTERNET_FLAG_RELOAD | #INTERNET_FLAG_PRAGMA_NOCACHE
    ;*tHTTP\lFlags = #INTERNET_FLAG_NO_CACHE_WRITE | #INTERNET_FLAG_RELOAD | #INTERNET_FLAG_PRAGMA_NOCACHE
  EndIf
but nothing changed... i tested it in curl with correct cookie it works...
thanks!