Giter VIP home page Giter VIP logo

nsis-nsxfer's Introduction

NSxfer (NSIS plugin)

NSxfer gives you the means to perform complex HTTP/HTTPS transfers from a NSIS script

License: zlib/libpng Latest Release Downloads GitHub issues

Features:

  • Multi threaded: transfer multiple files in parallel
  • Asynchronous: start a download now, check its status later
  • Aggressive: multiple attempts to connect, reconnect, resume interrupted transfers, etc.
  • NSIS aware: download files at any installation stage (from .onInit callback, from Sections, from custom pages, silent installers, etc.)
  • Informative: plenty of useful information is available for each transfer (size, speed, HTTP status, HTTP headers, etc)
  • Supports all relevant HTTP verbs (GET, POST, PUT, HEAD, etc)
  • Supports custom HTTP headers and data
  • Supports proxy servers (both authenticated and open)
  • Supports files larger than 4GB
  • Can download remote content to RAM instead of a file
  • Works well in 64-bit NSIS builds
  • Many more... Check out the included readme file

Basic usage:

  • HTTP GET example:
NSxfer::Transfer /URL "https://httpbin.org/get?param1=1&param2=2" /LOCAL "$TEMP\Response.json" /END
Pop $0  ; "OK" for success
  • HTTP POST application/json:
NSxfer::Transfer /URL "https://httpbin.org/post?param1=1&param2=2" /LOCAL "$TEMP\MyFile.json" /METHOD POST /DATA '{"number_of_the_beast" : 666}' /HEADERS "Content-Type: application/json" /END
Pop $0  ; "OK" for success
  • HTTP POST application/x-www-form-urlencoded:
NSxfer::Transfer /URL "https://httpbin.org/post?param1=1&param2=2" /LOCAL "$TEMP\MyFile.json" /METHOD POST /DATA 'User=My+User&Pass=My+Pass' /HEADERS "Content-Type: application/x-www-form-urlencoded" /END
Pop $0  ; "OK" for success

nsis-nsxfer's People

Contributors

negrutiu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

clairestreb kirb

nsis-nsxfer's Issues

400 BAD REQUEST if method name is not upper case

BAD REQUEST received if the method name is not upper cased

NSxfer::Transfer /URL https://httpbin.org/post /LOCAL none /METHOD post /DATA '{"number_of_the_beast" : 666}' /HEADERS "Content-Type: application/json" /END
Pop $0 ; "Bad Request"

NSxfer::Transfer /URL https://httpbin.org/post /LOCAL none /METHOD POST /DATA '{"number_of_the_beast" : 666}' /HEADERS "Content-Type: application/json" /END
Pop $0 ; "OK"

failed to retrieve memory content when domain under cloudflare

The code has been working perfectly before, but recently when I migrate my domain name to cloudflare, the code couldn't get memory content, It show Remote-Content: "".Is there any way to solve this problem?

Thank you very much.

          You can retrieve the memory content like this:
NSxfer::Request /URL "https://httpbin.org/get?param1=1&param2=2" /LOCAL memory /END
Pop $0		; Transfer ID
NSxfer::Wait /ID $0
Pop $1		; Wait for transfer to complete
NSxfer::Query /ID $0 /CONTENT /END
Pop $1		; Remote-content as string truncated to ${NSIS_MAX_STRLEN}. Empty string in case of errors
DetailPrint 'Remote-Content: "$1"'

Indeed, I've switched developent to NScurl.
It's built on top of libcurl which I think it's far superior to the native windows API.
With NScurl the same code would look like:

NScurl::http GET "https://httpbin.org/get?param1=1&param2=2" "MEMORY" /RETURN "@recvdata@" /END
Pop $0
DetailPrint 'Remote-Content: "$0"'

NScurl is newer and better. I recommend it.
Thanks for your kind words and enjoy my NSIS plugin(s)...

Originally posted by @negrutiu in #2 (comment)

Option for `NSxfer::Transfer` to return the request ID

NSxfer::Transfer currently returns the transfer status (i.e. "OK" for success) but no other information.

Add a new parameter /RETURNID to instruct Transfer to return the unique request ID.
The ID can later be passed to NSxfer::Query to get additional information.

Example:

NSxfer::Transfer /URL "https://wikipedia.org" /LOCAL memory /RETURNID /END
Pop $0 ; Request ID

NSxfer::Query /ID $0 /ERRORTEXT /CONTENT /SPEED /END
Pop $1 ; Transfer status ("OK" for success)
Pop $2 ; Remote-Content from memory
Pop $3 ; Transfer speed (i.e. "50 MB/s")

Transfers fail when started from .onInit (GH-6 regression)

When called from the .onInit NSIS function, transfers will not start.
This is a regression caused by the security checks added in GH-6.
Exported functions receive a NULL parent window during .onInit, which is quickly rejected by our new validations.
NULL windows should be treated as valid.

Downloads stop at 5MB and silently fail

I am having an issue downloading larger files (5MB +). They stop at exactly 5.00 MB (5,242,880 bytes).

I am using NSIS 3.09 x86-unicode and tested on Windows 11 22H2 x64 and Windows Server 2016 x64.

The below is a simple script that can be used for testing.

Test Script
OutFile NSxferTest.exe

Section -

	NSxfer::Request /METHOD GET /INTERNETFLAG INTERNET_FLAG_NO_CACHE_WRITE /URL "https://download-installer.cdn.mozilla.net/pub/firefox/releases/116.0/linux-x86_64/en-US/firefox-116.0.tar.bz2" /LOCAL "$exedir\test.zip" /END
	Pop $0
	DetailPrint "Got transfer id $0"

	NSxfer::Wait /ID $0 /END
	Pop $0

	NSxfer::Query /ID $0 /STATUS /WININETSTATUS /FILESIZE /RECVSIZE /ERRORCODE /ERRORTEXT /END
	Pop $0
	Pop $1
	Pop $2
	Pop $3
	Pop $4
	Pop $5

	DetailPrint "STATUS: $0"
	DetailPrint "WININETSTATUS: $1"
	DetailPrint "FILESIZE: $2"
	DetailPrint "RECVSIZE: $3"
	DetailPrint "ERRORCODE: $4"
	DetailPrint "ERRORTEXT: $5"

SectionEnd
Output
Got transfer id 1
STATUS: 
WININETSTATUS: 
FILESIZE: 
RECVSIZE: 
ERRORCODE: 
ERRORTEXT: 
Completed

If I use NSxfer::Transfer the result on the stack is "OK".

How to retrieve memory content?

Thank you for this great plugin. I noticed this plugin could download remote content to memory buffer, but how to retrieve memory content to Nsis script?

And I noticed you develop another plugin nsis-nscurl, which is best?

Stack Corruption Issue

Hello,

Thanks for the great plugin.

I'm having an issue where calling NSxfer is causing stack corruption. I'm using the x86-unicode version v1.2023.4.9 with NSIS v3.08.

I was having an issue with $0 not being set to the correct value after calling a function, so I used the Debug plugin to take a look.

It looks like the stack is being emptied or having things placed back in it unpredictably after calling the plugin.

I pushed a bunch of strings containing "Stack test", then call the plugin, and then use Debug::Stack to check the stack.

Here's the stack immediately before NSxfer::Transfer:
image

Here's the stack immediately after:
image

As you can see, the only thing on the stack any more is the RETURNID from the plugin.

Here's the code I'm using to call the plugin in this case:
NSxfer::Transfer /MODE SILENT /URL "http://127.0.0.1:9100/transmission/rpc/" /METHOD "GET" /LOCAL "MEMORY" /RETURNID

The whole NSIS script: https://gist.github.com/sopadelata/7e34387adf4d411e00d0cb8df511b2f2#file-gistfile1-txt-L162

(relevant part @ line 162)

Plugin hangs when unloading

On rare occasions NSxfer might hang when unloading
It happens when calling NSxfer::Query only, and no other exported function
When it happens the installer remains silently hung in the background

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.