Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #10123 > unrolled thread

chttp class can it do this?

Started byMartin <Martin@spam.spam>
First post2017-02-03 09:28 +0000
Last post2017-02-06 13:57 +0000
Articles 13 — 3 participants

Back to article view | Back to comp.lang.clipper.visual-objects


Contents

  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

#10123 — chttp class can it do this?

FromMartin <Martin@spam.spam>
Date2017-02-03 09:28 +0000
Subjectchttp class can it do this?
Message-ID<o71id4$adb$1@dont-email.me>
I cannot show the exact link as it contains commercially sensitive 
information so I have replaced things

site        is site name (a .co.uk)
emailaddr   is email address
PW          is password
nameoffile  is what I am getting

http://site:7004/webconnect/service.ashx?Cmd=getresource&Email=emailaddr&password=PW&resourceid=nameoffile

This in Firefox offers to download the file to its downloads.

I can connect and it tries to download but fails.

As it is a ASP based system the file does not appear without the call, 
and there is no view mode.

So I have to download it to the local drive.

So I either need to find a small program to download this ALA of 
Firefox, OR do it in VO code.

I am experimenting with WGET




Thanks

Martin

[toc] | [next] | [standalone]


#10124

FromJohnMartens <martens@tennishulp.info>
Date2017-02-03 10:44 +0100
Message-ID<o71jau$d0v$1@dont-email.me>
In reply to#10123
This one from Norbert was often helpfull to me

GetDocumentByGetOrPost("site:7004","/webconnect/service.ashx?Cmd="+getresource+"&Email="+emailaddr+"&password="+PW&,resourceid=nameoffile","YourHeader","POST")

Hope it helps you on the right track

John Martens


METHOD GetDocumentByGetOrPost(cIP, cDocument, cData, cHeader, cMethod, 
nP, nFlags) CLASS cHttp
	***************************************
	//	GET or POST - that's the question
	//	Norbert Kolb, 11/17/03, 12/02/04, 09/02/04 02/25/05
	//	UG Bodensee (A, CH, D, FL)
	***************************************
	//	First the InternetOpen function is called to initialize the
	//	remaining functions. Then the InternetConnect function is called
	//	to identify the type of service being requested. This is necessary
	//	as the same set of functions can be used to interact with a number
	//	of different servers.
	***************************************
	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
		SELF:nPort := nP
	ENDIF
		
	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
	        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	



Op 3-2-2017 om 10:28 schreef Martin:
> I cannot show the exact link as it contains commercially sensitive
> information so I have replaced things
>
> site        is site name (a .co.uk)
> emailaddr   is email address
> PW          is password
> nameoffile  is what I am getting
>
> http://site:7004/webconnect/service.ashx?Cmd=getresource&Email=emailaddr&password=PW&resourceid=nameoffile
>
>
> This in Firefox offers to download the file to its downloads.
>
> I can connect and it tries to download but fails.
>
> As it is a ASP based system the file does not appear without the call,
> and there is no view mode.
>
> So I have to download it to the local drive.
>
> So I either need to find a small program to download this ALA of
> Firefox, OR do it in VO code.
>
> I am experimenting with WGET
>
>
>
>
> Thanks
>
> Martin

[toc] | [prev] | [next] | [standalone]


#10125

FromMartin <Martin@spam.spam>
Date2017-02-03 10:12 +0000
Message-ID<o71kus$idc$1@dont-email.me>
In reply to#10124
I will check this over thanks, but worst case WGET works, just very clunky

On 03/02/2017 09:44, JohnMartens wrote:
> This one from Norbert was often helpfull to me
>
> GetDocumentByGetOrPost("site:7004","/webconnect/service.ashx?Cmd="+getresource+"&Email="+emailaddr+"&password="+PW&,resourceid=nameoffile","YourHeader","POST")
>
>
> Hope it helps you on the right track
>
> John Martens
>
>
> METHOD GetDocumentByGetOrPost(cIP, cDocument, cData, cHeader, cMethod,
> nP, nFlags) CLASS cHttp
>     ***************************************
>     //    GET or POST - that's the question
>     //    Norbert Kolb, 11/17/03, 12/02/04, 09/02/04 02/25/05
>     //    UG Bodensee (A, CH, D, FL)
>     ***************************************
>     //    First the InternetOpen function is called to initialize the
>     //    remaining functions. Then the InternetConnect function is called
>     //    to identify the type of service being requested. This is
> necessary
>     //    as the same set of functions can be used to interact with a
> number
>     //    of different servers.
>     ***************************************
>     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
>         SELF:nPort := nP
>     ENDIF
>
>     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
>             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
>
>
>
> Op 3-2-2017 om 10:28 schreef Martin:
>> I cannot show the exact link as it contains commercially sensitive
>> information so I have replaced things
>>
>> site        is site name (a .co.uk)
>> emailaddr   is email address
>> PW          is password
>> nameoffile  is what I am getting
>>
>> http://site:7004/webconnect/service.ashx?Cmd=getresource&Email=emailaddr&password=PW&resourceid=nameoffile
>>
>>
>>
>> This in Firefox offers to download the file to its downloads.
>>
>> I can connect and it tries to download but fails.
>>
>> As it is a ASP based system the file does not appear without the call,
>> and there is no view mode.
>>
>> So I have to download it to the local drive.
>>
>> So I either need to find a small program to download this ALA of
>> Firefox, OR do it in VO code.
>>
>> I am experimenting with WGET
>>
>>
>>
>>
>> Thanks
>>
>> Martin

[toc] | [prev] | [next] | [standalone]


#10126

FromMartin <Martin@spam.spam>
Date2017-02-03 10:23 +0000
Message-ID<o71lk2$l4k$1@dont-email.me>
In reply to#10124
Hmm doesn't appear to work

InternetQueryOption not found in repo anywhere so sectioned off

Returned file is zero length


I wil continue trying things out and see what happens

On 03/02/2017 09:44, JohnMartens wrote:
> This one from Norbert was often helpfull to me
>
> GetDocumentByGetOrPost("site:7004","/webconnect/service.ashx?Cmd="+getresource+"&Email="+emailaddr+"&password="+PW&,resourceid=nameoffile","YourHeader","POST")
>
>
> Hope it helps you on the right track
>
> John Martens
>
>
> METHOD GetDocumentByGetOrPost(cIP, cDocument, cData, cHeader, cMethod,
> nP, nFlags) CLASS cHttp
>     ***************************************
>     //    GET or POST - that's the question
>     //    Norbert Kolb, 11/17/03, 12/02/04, 09/02/04 02/25/05
>     //    UG Bodensee (A, CH, D, FL)
>     ***************************************
>     //    First the InternetOpen function is called to initialize the
>     //    remaining functions. Then the InternetConnect function is called
>     //    to identify the type of service being requested. This is
> necessary
>     //    as the same set of functions can be used to interact with a
> number
>     //    of different servers.
>     ***************************************
>     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
>         SELF:nPort := nP
>     ENDIF
>
>     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
>             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
>
>
>
> Op 3-2-2017 om 10:28 schreef Martin:
>> I cannot show the exact link as it contains commercially sensitive
>> information so I have replaced things
>>
>> site        is site name (a .co.uk)
>> emailaddr   is email address
>> PW          is password
>> nameoffile  is what I am getting
>>
>> http://site:7004/webconnect/service.ashx?Cmd=getresource&Email=emailaddr&password=PW&resourceid=nameoffile
>>
>>
>>
>> This in Firefox offers to download the file to its downloads.
>>
>> I can connect and it tries to download but fails.
>>
>> As it is a ASP based system the file does not appear without the call,
>> and there is no view mode.
>>
>> So I have to download it to the local drive.
>>
>> So I either need to find a small program to download this ALA of
>> Firefox, OR do it in VO code.
>>
>> I am experimenting with WGET
>>
>>
>>
>>
>> Thanks
>>
>> Martin

[toc] | [prev] | [next] | [standalone]


#10127

Fromnk <n.kolb@aon.at>
Date2017-02-03 13:15 +0100
Message-ID<o71s8a$1os$1@gioia.aioe.org>
In reply to#10126
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

[toc] | [prev] | [next] | [standalone]


#10128

FromMartin <Martin@spam.spam>
Date2017-02-03 12:44 +0000
Message-ID<o71tsv$jvo$1@dont-email.me>
In reply to#10127
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
>

[toc] | [prev] | [next] | [standalone]


#10129

FromMartin <Martin@spam.spam>
Date2017-02-03 14:33 +0000
Message-ID<o72482$bvp$1@dont-email.me>
In reply to#10127
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
>

[toc] | [prev] | [next] | [standalone]


#10130

FromMartin <Martin@spam.spam>
Date2017-02-03 16:18 +0000
Message-ID<o72acn$4j7$1@dont-email.me>
In reply to#10127
ALL CLOSED NOW

Norbert helped me get it to work, and after a OEM ANSI issue all is 
doable in my executables, I can now write all the handling code and take 
it from there.

THANK YOU NORBERT


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
>

[toc] | [prev] | [next] | [standalone]


#10132

FromJohnMartens <martens@tennishulp.info>
Date2017-02-03 19:59 +0100
Message-ID<ca47a2b8-d33e-8a50-c744-1cf0886b71db@tennishulp.info>
In reply to#10130
Norbert was fast an very helpfull to me as well to solve HTTP problems I 
would never would have solved myself !!

Op 3-2-2017 om 17:18 schreef Martin:
> ALL CLOSED NOW
>
> Norbert helped me get it to work, and after a OEM ANSI issue all is
> doable in my executables, I can now write all the handling code and take
> it from there.
>
> THANK YOU NORBERT
>
>
> 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
>>
>

[toc] | [prev] | [next] | [standalone]


#10133

FromJohnMartens <martens@tennishulp.info>
Date2017-02-03 20:00 +0100
Message-ID<o72jsl$87q$2@dont-email.me>
In reply to#10130
Norbert was fast an very helpfull to me as well to solve HTTP problems I 
would never would have solved myself !!

Op 3-2-2017 om 17:18 schreef Martin:
> ALL CLOSED NOW
>
> Norbert helped me get it to work, and after a OEM ANSI issue all is
> doable in my executables, I can now write all the handling code and take
> it from there.
>
> THANK YOU NORBERT
>
>
> 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
>>
>

[toc] | [prev] | [next] | [standalone]


#10131

FromMartin <Martin@spam.spam>
Date2017-02-03 16:35 +0000
Message-ID<o72bdr$8gs$1@dont-email.me>
In reply to#10123
For anyone trying this make sure you setansi(True) before any web access 
happens.

On 03/02/2017 09:28, Martin wrote:
> I cannot show the exact link as it contains commercially sensitive
> information so I have replaced things
>
> site        is site name (a .co.uk)
> emailaddr   is email address
> PW          is password
> nameoffile  is what I am getting
>
> http://site:7004/webconnect/service.ashx?Cmd=getresource&Email=emailaddr&password=PW&resourceid=nameoffile
>
>
> This in Firefox offers to download the file to its downloads.
>
> I can connect and it tries to download but fails.
>
> As it is a ASP based system the file does not appear without the call,
> and there is no view mode.
>
> So I have to download it to the local drive.
>
> So I either need to find a small program to download this ALA of
> Firefox, OR do it in VO code.
>
> I am experimenting with WGET
>
>
>
>
> Thanks
>
> Martin

[toc] | [prev] | [next] | [standalone]


#10134

Fromnk <n.kolb@aon.at>
Date2017-02-05 23:52 +0100
Message-ID<o78ac9$1iro$1@gioia.aioe.org>
In reply to#10131
Hello Martin,
in this case use low level functions instead memowrite()

pHandle := FCreate("_Martin.png", FC_NORMAL)
FWrite(pHandle, cPage, SLen(cPage))
FClose(pHandle)

Norbert

Am 03.02.2017 um 17:35 schrieb Martin:
> For anyone trying this make sure you setansi(True) before any web access
> happens.
>

[toc] | [prev] | [next] | [standalone]


#10135

FromMartin <Martin@spam.spam>
Date2017-02-06 13:57 +0000
Message-ID<o79v96$e0k$1@dont-email.me>
In reply to#10134
I did that, no difference, but setansi fixed it nicely

On 05/02/2017 22:52, nk wrote:
> Hello Martin,
> in this case use low level functions instead memowrite()
>
> pHandle := FCreate("_Martin.png", FC_NORMAL)
> FWrite(pHandle, cPage, SLen(cPage))
> FClose(pHandle)
>
> Norbert
>
> Am 03.02.2017 um 17:35 schrieb Martin:
>> For anyone trying this make sure you setansi(True) before any web access
>> happens.
>>
>

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.clipper.visual-objects


csiph-web