Skip to content

net.http ​

This module provides various operational support for http. The currently available interfaces are as follows:

http.download ​

  • Download http file

Function Prototype ​

API

lua
http.download(url: <string>, outputfile: <string>, opt: <table>)

Parameter Description ​

ParameterDescription
urlRequired. URL to download
outputfileRequired. Output file path
optOptional. Option parameters, supports the following:
- headers - HTTP headers
- timeout - Timeout duration
- useragent - User agent

Return Value ​

TypeDescription
booleanReturns true on success, false on failure

Usage ​

This interface is relatively simple, is simply download files.

lua
import("net.http")

http.download("https://xmake.io", "/tmp/index.html")