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


Groups > comp.lang.clipper.visual-objects > #10124

Re: chttp class can it do this?

From JohnMartens <martens@tennishulp.info>
Newsgroups comp.lang.clipper.visual-objects
Subject Re: chttp class can it do this?
Date 2017-02-03 10:44 +0100
Organization A noiseless patient Spider
Message-ID <o71jau$d0v$1@dont-email.me> (permalink)
References <o71id4$adb$1@dont-email.me>

Show all headers | View raw


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

Back to comp.lang.clipper.visual-objects | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


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