Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Martin Newsgroups: comp.lang.clipper.visual-objects Subject: Re: chttp class can it do this? Date: Fri, 3 Feb 2017 14:33:15 +0000 Organization: A noiseless patient Spider Lines: 206 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 3 Feb 2017 14:31:31 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="83b7757f7246e8e7e6cd0e21b7fe52c7"; logging-data="12281"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18gWwtL289+0ycjJJMV448n" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 In-Reply-To: Cancel-Lock: sha1:0AazvrDMy0/rrdyICL5CUXGG1ys= Xref: csiph.com comp.lang.clipper.visual-objects:10129 Hello Norbert Still having issues, the problem is I do not really understand HTML protocols, only been a profession programmer for 30 years. Can I email you the real URL please? The server is a private server on the internet, and I process downloaded transactions from hand held kit. The newest mod is that the customer wants us to download the signatures from the site using URLs embedded into the transaction files. The engine to process all of this is the server section of my bar code and processing system (Ginny helped me get the IP going). Everything else I have a handle on and doing it natively in VO will be neater than using WGET (that does work but clunky). From the local storage I will be able to display the signatures against the order, or the delivery stillage. Thank you Martin 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 >