Announcement

Collapse
No announcement yet.

Server Exchange

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #21
    I have read the parameters are encrypted with https.
    https://stackoverflow.com/questions/...urls-encrypted

    Still want to be sure nothing more is seen than needed.
    Never considered parameters might be stored if coming from a browser.

    Comment


    • #22
      Originally posted by Mike Doty View Post
      I have read the parameters are encrypted with https.
      https://stackoverflow.com/questions/...urls-encrypted

      Still want to be sure nothing more is seen than needed.
      Never considered parameters might be stored if coming from a browser.
      Parameters are part of the URL with a GET - they will be stored in both the browser and the server logs.
      Parameters sent with POST are not stored anywhere - they are ephemeral and only exist in the HTTPS encrypted request, as are any Headers in the request.

      Comment


      • #23
        Thanks. I read that the parameters are encrypted, but didn't consider logs!
        https://www.quora.com/Is-the-URL-enc...-HTTPS?share=1

        Comment


        • #24
          Method Not Allowed with "POST".
          GetMethod 0="POST" all others "GET"
          Code:
          #DIM ALL
          'https://forum.powerbasic.com/forum/jose-s-corner/source-code-ab/51694-winhhtp-com-examples
          #INCLUDE "httprequest.inc" 'GetOrPost.bas
          #INCLUDE "ole2utils.inc"
          
          FUNCTION PBMAIN()
           LOCAL GetMethod AS LONG  '0=POST other=GET 'corrected
           LOCAL wsurl,wsusername,wspassword,wsrequest,wsdata,wserror AS WSTRING
          
           GetMethod  = 0 '0=POST
           wsURL      = "https://dotysoftware.com/test.txt"
           wsUserName = ""
           wsPassword = ""
           wsRequest  = ""
           wsError    =  GetOrPost(GetMethod,wsUrl,wsUsername,wsPassword,wsRequest,wsData)
           IF wsError = "OK" THEN
            ? wsData,,"GetPost OK"
           ELSE
            ? wsError,,"GetPost Error"
           END IF
          END FUNCTION
          
          FUNCTION GetOrPost(GetMethod AS LONG   ,_
                    wsURL            AS WSTRING,_
                    wsUserName       AS WSTRING,_
                    wsPassword       AS WSTRING,_
                    wsRequest        AS WSTRING,_
                    wsDataReturned   AS WSTRING) AS WSTRING 'returns OK or error message
          
           IF GetMethod THEN 'GET REQUEST
            IF LEFT$(wsRequest,1) <> "?" THEN wsRequest = "?" + wsRequest 'add ? if GET
           ELSE              'POST REQUEST
            IF LEFT$(wsRequest,1) = "?"  THEN wsRequest = MID$(wsRequest,2) 'remove ? if POST
           END IF
           REM ? wsRequest,,"GetMethod"+STR$(GetMethod)
          
           RESET wsDataReturned
           DIM pHttpReq AS IWinHttpRequest
           pHttpReq = NEWCOM "WinHttp.WinHttpRequest.5.1"
           IF ISNOTHING(pHttpReq) THEN
            ? "WinHttpRequest.5.1 failure",%MB_ICONERROR OR %MB_SYSTEMMODAL,FUNCNAME$
            EXIT FUNCTION
           END IF
          
           TRY
            IF GetMethod THEN
              pHttpReq.Open "GET",  wsURL + wsRequest, 0
            ELSE
              pHttpReq.Open "POST", wsURL + wsRequest, 0
            END IF
          
            'skip SetCredetials if either are missing
            IF LEN(wsUserName) AND  LEN(wsPassword) THEN
             pHttpReq.SetCredentials wsUserName, wsPassword, %HTTPREQUEST_SETCREDENTIALS_FOR_SERVER
            END IF
          
            IF GetMethod THEN
             pHttpReq.Send
            ELSE
             pHttpReq.Send(wsRequest)
            END IF
            LOCAL iSucceeded AS LONG
            iSucceeded = pHttpReq.WaitForResponse(5) 'added 9/22/22
            IF pHttpReq.StatusText <> "OK" THEN
             IF pHttpReq.StatusText = "" THEN
              FUNCTION = "No send response"
             ELSE
              FUNCTION = pHttpReq.StatusText
             END IF
            ELSE  'success
             wsDataReturned = pHttpReq.ResponseText
             FUNCTION = pHttpReq.StatusText
            END IF
           CATCH
            OleShowErrorInfo OBJRESULT
           END TRY
           END FUNCTION
          Last edited by Mike Doty; 22 Sep 2022, 05:22 PM.

          Comment


          • #25
            Brainf*rt?

            > LOCAL GetMethod AS LONG '0=POST other=POST

            ? LOCAL GetMethod AS LONG '0=POST other=GET ?

            Comment


            • #26
              Typo. If you know of another routine like this that supports POST, please inform. I'll be looking.
              Gary, GET isn't all bad. It passed everything I threw at it.

              Comment


              • #27
                I love this forum! You can ask a question and it can take on a life of its own without having to be there every second.

                I had to make a presentation this morning and on the way there I got sick at my stomach. The only thing I could do was take of my hat and vomit into the hat! Yuck!

                But then when I got home, this thread had even more information for me to work with.

                Is that a fair trade, or what!

                Comment


                • #28
                  Gary
                  We are losing members rapidly, hope that you can help out other existing members more often.
                  Sad to see the dwindling numbers of members in this forum.

                  Comment


                  • #29
                    Originally posted by Mike Doty View Post
                    Method Not Allowed with "POST".
                    Oops,

                    Add:
                    pHttpReq.SetRequestHeader "Content-Type","application/x-www-form-urlencoded"
                    ​before
                    pHttpReq.Send(wsRequest)

                    Oh, and make your URL point to a PHP script (.php) , not a text file (.txt)

                    Comment


                    • #30
                      Originally posted by Anne Wilson View Post
                      Gary
                      We are losing members rapidly, hope that you can help out other existing members more often.
                      Sad to see the dwindling numbers of members in this forum.
                      And the relevance of this post in this thread is......?

                      Comment


                      • #31
                        Reading documents:
                        https://learn.microsoft.com/en-us/wi...in-winhttp-5-1

                        1. The Open with "POST" was incorrectly appending the wsrequest (just like "GET")
                        2. Added pHttpReq.SetRequestHeader "Content-Type","application/x-www-form-urlencoded"
                        Still get "Method Not Allowed" when using "POST"
                        Code:
                        #DIM ALL
                        'https://forum.powerbasic.com/forum/jose-s-corner/source-code-ab/51694-winhhtp-com-examples
                        #INCLUDE "httprequest.inc" 'GetOrPost.bas
                        #INCLUDE "ole2utils.inc"
                        
                        FUNCTION PBMAIN()
                         LOCAL GetMethod AS LONG  '1=GET other=POST
                         LOCAL wsurl,wsusername,wspassword,wsrequest,wsdata,wserror AS WSTRING
                        
                         GetMethod  = 1 '0=POST,1=GET
                         wsURL      = "https://dotysoftware.com/test.txt"
                         wsUserName = ""
                         wsPassword = ""
                         wsRequest  = ""
                         wsError    =  GetOrPost(GetMethod,wsUrl,wsUsername,wsPassword,wsRequest,wsData)
                         IF wsError = "OK" THEN
                          ? wsData,,"GetPost OK"
                         ELSE
                          ? wsError,,"GetPost Error"
                         END IF
                        END FUNCTION
                        
                        FUNCTION GetOrPost(GetMethod AS LONG   ,_
                                  wsURL            AS WSTRING,_
                                  wsUserName       AS WSTRING,_
                                  wsPassword       AS WSTRING,_
                                  wsRequest        AS WSTRING,_
                                  wsDataReturned   AS WSTRING) AS WSTRING 'returns OK or error message
                        
                         IF GetMethod THEN 'GET REQUEST
                          IF LEFT$(wsRequest,1) <> "?" THEN wsRequest = "?" + wsRequest 'add ? if GET
                         ELSE              'POST REQUEST
                          IF LEFT$(wsRequest,1) = "?"  THEN wsRequest = MID$(wsRequest,2) 'remove ? if POST
                         END IF
                        
                         RESET wsDataReturned
                         DIM pHttpReq AS IWinHttpRequest
                         pHttpReq = NEWCOM "WinHttp.WinHttpRequest.5.1"
                         IF ISNOTHING(pHttpReq) THEN
                          ? "WinHttpRequest.5.1 failure",%MB_ICONERROR OR %MB_SYSTEMMODAL,FUNCNAME$
                          EXIT FUNCTION
                         END IF
                        
                         TRY
                          IF GetMethod THEN
                            pHttpReq.Open "GET",  wsURL + wsRequest, 0  'GET
                          ELSE
                            pHttpReq.Open "POST", wsURL, 0              'POST 'no longer adds request
                          END IF
                        
                          'skip SetCredetials if either are missing
                          IF LEN(wsUserName) AND  LEN(wsPassword) THEN
                           pHttpReq.SetCredentials wsUserName, wsPassword, %HTTPREQUEST_SETCREDENTIALS_FOR_SERVER
                          END IF
                        
                          IF GetMethod THEN  'GET
                           pHttpReq.Send
                          ELSE               'POST
                           pHttpReq.SetRequestHeader "Content-Type","application/x-www-form-urlencoded" 'added
                           pHttpReq.Send(wsRequest)
                          END IF
                        
                          LOCAL iSucceeded AS LONG
                          iSucceeded = pHttpReq.WaitForResponse(5) 'added 9/22/22
                          IF pHttpReq.StatusText <> "OK" THEN
                           IF pHttpReq.StatusText = "" THEN
                            FUNCTION = "No send response"
                           ELSE
                            FUNCTION = pHttpReq.StatusText
                           END IF
                          ELSE  'success
                           wsDataReturned = pHttpReq.ResponseText
                           FUNCTION = pHttpReq.StatusText
                          END IF
                         CATCH
                          OleShowErrorInfo OBJRESULT
                         END TRY
                        END FUNCTION

                        Comment


                        • #32
                          Found this that is using "POST" !!
                          https://www.808.dk/?code-simplewinhttprequest

                          Comment


                          • #33
                            Originally posted by Mike Doty View Post
                            Reading documents:
                            https://learn.microsoft.com/en-us/wi...in-winhttp-5-1

                            1. The Open with "POST" was incorrectly appending the wsrequest (just like "GET")
                            2. Added pHttpReq.SetRequestHeader "Content-Type","application/x-www-form-urlencoded"
                            Still get "Method Not Allowed" when using "POST"
                            Code:
                            ...
                            wsURL = "https://dotysoftware.com/test.txt"
                            ...
                            Still POSTing to a .txt file ?

                            This returns "Method not allowed":
                            wsURL = "https://dotysoftware.com/test.txt"
                            This returns "Not found"
                            wsURL = "https://dotysoftware.com/test.php"

                            Comment


                            • #34
                              Yes. Trying to get the contents of the 47-byte file at https://dotysoftware.com/test.txt using "POST" instead of "GET".
                              I also get file "Not Found" if a file like "test1.txt" does not exist. I am studying a VBSCRIPT
                              https://www.808.dk/?code-simplewinhttprequest

                              Comment


                              • #35
                                Originally posted by Mike Doty View Post
                                Yes. Trying to get the contents of the 47-byte file at https://dotysoftware.com/test.txt using "POST" instead of "GET".
                                I also get file "Not Found" if a file like "test1.txt" does not exist. I am studying a VBSCRIPT
                                https://www.808.dk/?code-simplewinhttprequest
                                ​You still don't seem to have grasped the concept of POSTing.

                                Try this.
                                '
                                Code:
                                #DIM ALL
                                'https://forum.powerbasic.com/forum/jose-s-corner/source-code-ab/51694-winhhtp-com-examples
                                #INCLUDE "httprequest.inc" 'GetOrPost.bas
                                #INCLUDE "ole2utils.inc"
                                
                                FUNCTION PBMAIN()
                                 LOCAL wsurl,wsusername,wspassword,wsrequest,wsdata,wserror AS WSTRING
                                 wsURL      = "https://camcopng.com/dotytest.php"
                                 wsRequest  = "Data=abc"
                                 wsError    =  PostReq(wsUrl,wsRequest,wsData)
                                 IF wsError = "OK" THEN
                                  ? wsData,,"GetPost OK"
                                 ELSE
                                  ? wsError,,"GetPost Error"
                                 END IF
                                END FUNCTION
                                
                                FUNCTION PostReq(wsURL AS WSTRING, wsRequest AS WSTRING,wsDataReturned AS WSTRING) AS WSTRING 'returns OK or error message
                                     RESET wsDataReturned
                                     DIM pHttpReq AS IWinHttpRequest
                                     pHttpReq = NEWCOM "WinHttp.WinHttpRequest.5.1"
                                     IF ISNOTHING(pHttpReq) THEN
                                      ? "WinHttpRequest.5.1 failure",%MB_ICONERROR OR %MB_SYSTEMMODAL,FUNCNAME$
                                      EXIT FUNCTION
                                     END IF
                                    TRY
                                       pHttpReq.Open "POST", wsURL, 0
                                       pHttpReq.SetRequestHeader "Content-Type","application/x-www-form-urlencoded"
                                       pHttpReq.Send(wsRequest)
                                       LOCAL iSucceeded AS LONG
                                       iSucceeded = pHttpReq.WaitForResponse(5) 'added 9/22/22
                                       IF pHttpReq.StatusText <> "OK" THEN
                                            IF pHttpReq.StatusText = "" THEN
                                                FUNCTION = "No send response"
                                            ELSE
                                                FUNCTION = pHttpReq.StatusText
                                            END IF
                                        ELSE  'success
                                            wsDataReturned = pHttpReq.ResponseText
                                            FUNCTION = pHttpReq.StatusText
                                        END IF
                                    CATCH
                                        OleShowErrorInfo OBJRESULT
                                    END TRY
                                 END FUNCTION
                                '


                                The content of dotytest.php:
                                Code:
                                <?php
                                if (!(isset($_POST['Data'])) ) {
                                die("No requested data");
                                }
                                $filename = $_POST['Data'].'.txt';
                                if (! is_readable($filename)) {
                                die($filename." was found");
                                }
                                $fh = fopen($filename,'r') or die("can't open ".$filename) ;
                                $readtext = fread($fh, filesize($filename));
                                fclose($fh);
                                echo $readtext;
                                ?>​
                                And the file abc.txt contains some random text

                                Comment


                                • #36
                                  Originally posted by Mike Doty View Post
                                  Yes. Trying to get the contents of the 47-byte file at https://dotysoftware.com/test.txt using "POST" instead of "GET".
                                  I also get file "Not Found" if a file like "test1.txt" does not exist. I am studying a VBSCRIPT
                                  https://www.808.dk/?code-simplewinhttprequest
                                  getfile.php:
                                  Code:
                                  <?php
                                  if (!(isset($_POST['file'])) ) {
                                      die("No file requested");
                                  }
                                  $filename = $_POST['file'];
                                  if (! is_readable($filename)) {
                                      die($filename." was not found");
                                  }
                                  $fh = fopen($filename,'r') or die("can't open ".$filename) ;
                                  $readtext = fread($fh, filesize($filename));
                                  fclose($fh);
                                  echo $readtext;
                                  ?>​
                                  Get a file using POST:
                                  '
                                  Code:
                                  #COMPILE EXE "FileFromPost.exe
                                  #DIM ALL
                                  #INCLUDE "httprequest.inc" 'GetOrPost.bas
                                  #INCLUDE "ole2utils.inc"
                                  
                                  FUNCTION PBMAIN()
                                   LOCAL wsurl,wsusername,wsrequest,wsdata,wserror AS WSTRING
                                   wsURL      = "https://camcopng.com/getfile.php"
                                   wsRequest  = "file=test.txt"
                                   wsError    =  PostReq(wsUrl,wsRequest,wsData)
                                   IF wsError = "OK" THEN
                                    ? wsData,,"GetPost OK"
                                   ELSE
                                    ? wsError,,"GetPost Error"
                                   END IF
                                  END FUNCTION
                                  
                                  FUNCTION PostReq(wsURL AS WSTRING, wsRequest AS WSTRING,wsDataReturned AS WSTRING) AS WSTRING 'returns OK or error message
                                       RESET wsDataReturned
                                       DIM pHttpReq AS IWinHttpRequest
                                       pHttpReq = NEWCOM "WinHttp.WinHttpRequest.5.1"
                                       IF ISNOTHING(pHttpReq) THEN
                                        ? "WinHttpRequest.5.1 failure",%MB_ICONERROR OR %MB_SYSTEMMODAL,FUNCNAME$
                                        EXIT FUNCTION
                                       END IF
                                      TRY
                                         pHttpReq.Open "POST", wsURL, 0
                                         pHttpReq.SetRequestHeader "Content-Type","application/x-www-form-urlencoded"
                                         pHttpReq.Send(wsRequest)
                                         LOCAL iSucceeded AS LONG
                                         iSucceeded = pHttpReq.WaitForResponse(5) 'added 9/22/22
                                         IF pHttpReq.StatusText <> "OK" THEN
                                              IF pHttpReq.StatusText = "" THEN
                                                  FUNCTION = "No send response"
                                              ELSE
                                                  FUNCTION = pHttpReq.StatusText
                                              END IF
                                          ELSE  'success
                                              wsDataReturned = pHttpReq.ResponseText
                                              FUNCTION = pHttpReq.StatusText
                                          END IF
                                      CATCH
                                          OleShowErrorInfo OBJRESULT
                                      END TRY
                                   END FUNCTION
                                  '

                                  Comment


                                  • #37
                                    You still don't seem to have grasped the concept of POSTing.
                                    Stuart,
                                    I don't have php.
                                    Your code worked at the given link.

                                    This is Gary's thread so he might have a solution with the php.
                                    I will have to get back to this. It looks like POST should work without php.

                                    Note: The requests with "GET" do show up in my server log (as you said) with the user name, but without the password.
                                    I can live with that, but I do see a vbscript using post that isn't using php.

                                    Thanks for all the help, but I have to move on (for now.)
                                    Redundant, I know: https://www.808.dk/?code-simplewinhttprequest
                                    .

                                    Comment


                                    • #38
                                      Originally posted by Anne Wilson View Post
                                      Gary
                                      We are losing members rapidly, hope that you can help out other existing members more often.
                                      Sad to see the dwindling numbers of members in this forum.
                                      Agreed I love the solutions (when I understand them), I love the arguments and I love the confidence that I can ask my questions and get an answer.

                                      Adam, we need that upgrade - not because we really need an upgrade - but because we need to tell the world that we are progressing!

                                      And so this is the wrong thread? - too bad!!!
                                      [I]I made a coding error once - but fortunately I fixed it before anyone noticed[/I]
                                      Kerry Farmer

                                      Comment


                                      • #39
                                        Originally posted by Kerry Farmer View Post
                                        And so this is the wrong thread? - too bad!!!
                                        And that's the sort of attitude that sends forum members away.
                                        We don't come for moans about declining participation and yet another one in the interminable list of posts in numerous other threads rabbiting on about upgrades..
                                        We come here to discuss programming topics.

                                        Comment


                                        • #40
                                          Originally posted by Mike Doty View Post
                                          Stuart,
                                          I don't have php.
                                          Your code worked at the given link.

                                          This is Gary's thread so he might have a solution with the php.
                                          I will have to get back to this. It looks like POST should work without php.
                                          POST will work with any scripting language installed on your server, but you have to have something installed to handle it.

                                          https://aprelium.com/abyssws/features.html
                                          Abyss Web Server has been specially designed to make using scripts the simplest possible even on Windows platforms. Thanks to its CGI and ISAPI extensions interfaces, Abyss Web Server supports various scripting languages such as PHP, Perl, "Classic" ASP, Python, Ruby, Rebol and TCL.​

                                          https://aprelium.com/abyssws/php.html
                                          Abyss Web Server supports all PHP releases including all the PHP 4, PHP 5, PHP 7 and PHP 8 versions.

                                          Comment

                                          Working...
                                          X