tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

postdriver.nsi (1384B)


      1 ; Any copyright is dedicated to the Public Domain.
      2 ; http://creativecommons.org/publicdomain/zero/1.0/
      3 
      4 ; Simple driver for HttpPostFile, passes command line args to HttpPostFile::Post and
      5 ; writes the result string to a file for automated checking.
      6 ; Always specifies Content-Type: application/json
      7 ;
      8 ; Usage: posttest /postfile=postfile.json /url=http://example.com /resultfile=result.txt
      9 
     10 !include LogicLib.nsh
     11 !include FileFunc.nsh
     12 
     13 OutFile "postdriver.exe"
     14 RequestExecutionLevel user
     15 ShowInstDetails show
     16 Unicode true
     17 
     18 !addplugindir ..\..\..\Plugins
     19 
     20 Var PostFileArg
     21 Var UrlArg
     22 Var ResultFileArg
     23 Var ResultString
     24 
     25 Section
     26 
     27 StrCpy $ResultString "error getting command line arguments"
     28 
     29 ClearErrors
     30 ${GetParameters} $0
     31 IfErrors done
     32 
     33 ClearErrors
     34 ${GetOptions} " $0" " /postfile=" $PostFileArg
     35 IfErrors done
     36 
     37 ${GetOptions} " $0" " /url=" $UrlArg
     38 IfErrors done
     39 
     40 ${GetOptions} " $0" " /resultfile=" $ResultFileArg
     41 IfErrors done
     42 
     43 DetailPrint "POST File = $PostFileArg"
     44 DetailPrint "URL = $UrlArg"
     45 DetailPrint "Result File = $ResultFileArg"
     46 
     47 StrCpy $ResultString "error running plugin"
     48 HttpPostFile::Post $PostFileArg "Content-Type: application/json$\r$\n" $UrlArg
     49 Pop $ResultString
     50 
     51 done:
     52 ${If} $ResultString != "success"
     53 DetailPrint $ResultString
     54 ${EndIf}
     55 
     56 ClearErrors
     57 FileOpen $0 $ResultFileArg "w"
     58 ${Unless} ${Errors}
     59 FileWrite $0 $ResultString
     60 FileClose $0
     61 ${EndUnless}
     62 
     63 SectionEnd