Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.clipper.visual-objects > #10128
| From | Martin <Martin@spam.spam> |
|---|---|
| Newsgroups | comp.lang.clipper.visual-objects |
| Subject | Re: chttp class can it do this? |
| Date | 2017-02-03 12:44 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <o71tsv$jvo$1@dont-email.me> (permalink) |
| References | <o71id4$adb$1@dont-email.me> <o71jau$d0v$1@dont-email.me> <o71lk2$l4k$1@dont-email.me> <o71s8a$1os$1@gioia.aioe.org> |
Thankyou
On 03/02/2017 12:15, nk wrote:
> Hello Martin,
> I'm shure you can do that with my method GetDocumentByGetOrPost(). But
> you shold know a little bit more!
>
> _DLL FUNCTION InternetQueryOption ( hConnect AS PTR, ;
> dwOption AS DWORD, ;
> lpbuffer AS PTR, ;
> lpbufferlen AS PTR;
> ) ;
> AS LOGIC PASCAL:WININET.InternetQueryOptionA
>
> May be you need some defines
>
> DEFINE INTERNET_OPTION_SECURITY_FLAGS := 31
> DEFINE SECURITY_FLAG_IGNORE_UNKNOWN_CA := 256
> DEFINE INTERNET_OPTION_CONNECT_TIMEOUT := 2
> DEFINE INTERNET_OPTION_SEND_TIMEOUT := 5
> DEFINE INTERNET_OPTION_RECEIVE_TIMEOUT := 6
> DEFINE INTERNET_OPTION_DATA_SEND_TIMEOUT := 7
> DEFINE INTERNET_OPTION_DATA_RECEIVE_TIMEOUT := 8
>
> cUrl := "YourSite.Com" // without http://
> nP := 7004 // Port
> cDocument := "/webconnect/service.ashx?Cmd="+getresource+"&
> Email="+emailaddr+"&password="+PW+"&resourceid=nameoffile"
>
> cHeader := "" // May be you need a little bit more
> cMethod := "GET"
> cPostData := ""
>
> METHOD GetDocumentByGetOrPost(cIP, cDocument, cData, cHeader, cMethod,
> nP, nFlags, nTimeOut) CLASS cHttp
> ***************************************
> // GET or POST - that's the question
> // Norbert Kolb, 11/17/03, 12/02/04, 09/02/04 03/11/09
> // UG Bodensee (A, CH, D, FL)
> ***************************************
> // #L First the InternetOpen function is called to initialize the
> // #L remaining functions. Then the InternetConnect function is called
> // #L to identify the type of service being requested. This is
> necessary
> // #L as the same set of functions can be used to interact with a
> number
> // #L of different servers.
> // #P cIP: IP-adress like 30.234.128.6 or like www.myserver.com
> // #P cDocument: folder and filename of the html-page
> (/getorpost.php?text=Mit URL uebergeben)
> // #P cData: Data like files or variables
> // #P cHeader: Header Field Definitions
> // #P cMethod: "GET" or "POST", default: "GET"
> // #P nP: Port, default: 80, https: INTERNET_DEFAULT_HTTPS_PORT (443)
> // #P nFlags: default: 0, https: INTERNET_FLAG_SECURE
> // #P nTimeOut: If > 0 set TimeOut in seconds, used to send large files
> //
> // #R string with the html-page
> //
> ***************************************
> LOCAL lResult AS LOGIC
> LOCAL nDataLen AS DWORD
> LOCAL nBuffer AS DWORD
> LOCAL nBufferLen AS DWORD
> LOCAL cRet AS STRING
>
> Default(@cDocument, "")
> Default(@cData, "")
> Default(@cMethod, "GET")
> Default(@nP, SELF:nPort)
> Default(@nFlags, 0)
>
> IF _AND(DWORD(nFlags), INTERNET_FLAG_SECURE) = INTERNET_FLAG_SECURE
> nP := INTERNET_DEFAULT_HTTPS_PORT
> ENDIF
>
> SELF:nPort := nP
>
> IF SELF:hSession == NULL_PTR
> lResult := SELF:Open(NIL, SELF:cProxy)
> ELSE
> lResult := .T.
> ENDIF
>
> IF lResult
> // Identify the type of service that is being accessed
> IF SELF:hConnect == NULL_PTR .OR. SELF:cHostAddress <> cIP
> SELF:cHostAddress := cIP
> SELF:hConnect := InternetConnect(SELF:hSession, ;
> String2Psz(SELF:cHostAddress), ;
> nP, ;
> String2Psz(SELF:cUserName), ;
> String2Psz(SELF:cPassword), ;
> INTERNET_SERVICE_HTTP, ;
> nFlags, ;
> 0)
> ENDIF
>
> IF SELF:hConnect <> NULL_PTR
> IF !Empty(nTimeOut)
> SELF:InternetSetTimeOut(nTimeOut)
> ENDIF
> SELF:__SetStatusObject()
> // Once we've identified the service, we need to indicate
> the
> // page to which the data will be posted. In this
> example, it will
> // be "/getorpost.php"
> SELF:hRequest := HttpOpenRequest(SELF:hConnect, ; // hConnect
> String2Psz(cMethod), ; // lpszVerb
> String2Psz(cDocument), ; // pszObjectName
> String2Psz("HTTP/1.1"), ; // pszVersion
> NULL_PSZ, ; // pszReferer
> NULL_PSZ, ; // pszAcceptTypes
> nFlags, ; // dwFlags
> SELF:__GetStatusContext()) // dwContext
>
> IF SELF:hRequest <> NULL_PTR
> SELF:__SetStatus(SELF:hRequest)
> // We need to add a header to notify the web server
> that the
> // incoming data is form encoded and then send the
> request.
> IF cMethod == "POST"
> IF Empty(cHeader)
> cHeader := "Content-Type:
> application/x-www-form-urlencoded" + CrLf + HEADER_ACCEPT
> ENDIF
> ELSE
> IF Empty(cHeader)
> cHeader := HEADER_ACCEPT
> ENDIF
> ENDIF
>
> IF HttpAddRequestHeaders(SELF:hRequest, ;
> String2Psz(cHeader), ;
> SLen(cHeader), ;
> HTTP_ADDREQ_FLAG_ADD)
>
>
> // Sometimes you have to set SECURITY_FLAGS
> // InternetQueryOption(SELF:hRequest,
> INTERNET_OPTION_SECURITY_FLAGS, @nBuffer, @nBufferLen)
> // nBuffer := _OR(nBuffer,
> SECURITY_FLAG_IGNORE_UNKNOWN_CA)
> // InternetSetOption(SELF:hRequest,
> INTERNET_OPTION_SECURITY_FLAGS, @nBuffer, nBufferLen)
>
> nDataLen := SLen(cData)
>
> IF HttpSendRequest(SELF:hRequest, ;
> NULL, ;
> 0, ;
> PTR(_CAST, cData), ;
> nDataLen)
>
> // Finally, we need to collect our reward for
> all this effort
> SELF:GetResponseHeader()
> cRet := SELF:GetResponse()
>
> ENDIF // SendRequest
>
> SELF:CloseRequest()
>
> END // AddRequestHeaders
>
> ENDIF
>
> SELF:__DelStatusObject()
>
> ENDIF
>
> ENDIF
>
> RETURN cRet
>
>
> Hope this will help you
> Norbert
>
Back to comp.lang.clipper.visual-objects | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
chttp class can it do this? Martin <Martin@spam.spam> - 2017-02-03 09:28 +0000
Re: chttp class can it do this? JohnMartens <martens@tennishulp.info> - 2017-02-03 10:44 +0100
Re: chttp class can it do this? Martin <Martin@spam.spam> - 2017-02-03 10:12 +0000
Re: chttp class can it do this? Martin <Martin@spam.spam> - 2017-02-03 10:23 +0000
Re: chttp class can it do this? nk <n.kolb@aon.at> - 2017-02-03 13:15 +0100
Re: chttp class can it do this? Martin <Martin@spam.spam> - 2017-02-03 12:44 +0000
Re: chttp class can it do this? Martin <Martin@spam.spam> - 2017-02-03 14:33 +0000
Re: chttp class can it do this? Martin <Martin@spam.spam> - 2017-02-03 16:18 +0000
Re: chttp class can it do this? JohnMartens <martens@tennishulp.info> - 2017-02-03 19:59 +0100
Re: chttp class can it do this? JohnMartens <martens@tennishulp.info> - 2017-02-03 20:00 +0100
Re: chttp class can it do this? Martin <Martin@spam.spam> - 2017-02-03 16:35 +0000
Re: chttp class can it do this? nk <n.kolb@aon.at> - 2017-02-05 23:52 +0100
Re: chttp class can it do this? Martin <Martin@spam.spam> - 2017-02-06 13:57 +0000
csiph-web