Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Authentication issue with IntGetFile
#3
You can try to send custom headers with this function.

Member function Http.Get2
Code:
Copy      Help
function# $remoteFile str&data [flags] [inetFlags] [str&responseHeaders] [$sendHeaders] ;;flags: 1-3 cache flags, 16 download to file, 32 run in other thread

;Downloads web page or other file.
;Returns: 1 success, 0 failed.

;remotefile - file to download, relative to server. Examples: "index.htm", "images/earth.jpg".
;data - variable that receives file data. If flag 16 - variable that contains local file name.
;flags, inetflags, responseheaders - see IntGetFile. Does not support flags: 4, 8.

;REMARKS
;At first call Connect to connect to web server.

;Added in: QM 2.3.2.

;See also: <IntGetFile>


if(flags&0x10000) goto g1 ;;thread

if(!Cache(flags inetFlags)) ret

if(flags&0x10000=0) if(m_dlg or flags&32) ret Thread(1 &remoteFile "Downloading" remoteFile)
;g1
__HInternet hi=HttpOpenRequest(m_hi "GET" remoteFile 0 0 0 inetFlags 0); if(!hi) ret Error
if(!HttpSendRequest(hi sendHeaders -1 0 0)) ret Error
if(&responseHeaders and !GetResponseHeaders(hi responseHeaders)) ret Error
ret Read(hi data flags&16)

;note: HttpOpenRequestW does not support Unicode too.

example
Macro Macro2119
Code:
Copy      Help
Http h.Connect("blah.blah.org")
str headers=
;Host: blah.blah.org
;User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:22.0) Gecko/20100101 Firefox/22.0
;Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
;Accept-Language: en-US,en;q=0.5
;Accept-Encoding: gzip, deflate
;DNT: 1
;Connection: keep-alive
h.Get2(F"WebServiceManager2/..." outputString 0 0 0 headers)

HttpSendRequest will add/remove something, it also depends on inetFlags.
With Get2 don't use flag 32.


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)