From 5b4b9158799293eeaf8439d40a7845b5b0a5e125 Mon Sep 17 00:00:00 2001 From: Diego Nehab Date: Fri, 4 Mar 2016 16:16:41 -0300 Subject: Remove global PORT. Fix https redirect. --- doc/http.html | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'doc/http.html') diff --git a/doc/http.html b/doc/http.html index cd41c0d..3b7a8b1 100644 --- a/doc/http.html +++ b/doc/http.html @@ -112,12 +112,15 @@ the HTTP module:

+

+Note: These constants are global. Changing them will also +change the behavior other code that might be using LuaSocket. +

-- cgit v1.2.3-55-g6feb From 09ff9b650c3567c91eed62f4dd571729df2dedd4 Mon Sep 17 00:00:00 2001 From: "E. Westbrook" Date: Fri, 13 Jul 2018 12:52:26 -0600 Subject: http.lua: allow override of hard-coded 5 max redirects --- doc/http.html | 8 +++++--- src/http.lua | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'doc/http.html') diff --git a/doc/http.html b/doc/http.html index 3b7a8b1..78f785a 100644 --- a/doc/http.html +++ b/doc/http.html @@ -135,7 +135,8 @@ http.request{
  [step = LTN12 pump step,]
  [proxy = string,]
  [redirect = boolean,]
-  [create = function]
+  [create = function,]
+  [maxredirects = number]
}

@@ -185,6 +186,7 @@ Defaults to the LTN12 pump.step function. function from automatically following 301 or 302 server redirect messages;
  • create: An optional function to be used instead of socket.tcp when the communications socket is created. +
  • maxredirects: An optional number specifying the maximum number of redirects to follow. Defaults to 5 if not specified. A boolean false value means no maximum (unlimited).

    @@ -324,8 +326,8 @@ r, c = http.request {

    -Last modified by Diego Nehab on
    -Thu Apr 20 00:25:26 EDT 2006 +Last modified by Eric Westbrook on
    +Sat Feb 23 19:09:42 UTC 2019

    diff --git a/src/http.lua b/src/http.lua index a386165..8bda0d8 100644 --- a/src/http.lua +++ b/src/http.lua @@ -277,7 +277,9 @@ local function shouldredirect(reqt, code, headers) return (reqt.redirect ~= false) and (code == 301 or code == 302 or code == 303 or code == 307) and (not reqt.method or reqt.method == "GET" or reqt.method == "HEAD") - and (not reqt.nredirects or reqt.nredirects < 5) + and ((false == reqt.maxredirects) + or ((reqt.nredirects or 0) + < (reqt.maxredirects or 5))) end local function shouldreceivebody(reqt, code) @@ -299,6 +301,7 @@ local trequest, tredirect sink = reqt.sink, headers = reqt.headers, proxy = reqt.proxy, + maxredirects = reqt.maxredirects, nredirects = (reqt.nredirects or 0) + 1, create = reqt.create } -- cgit v1.2.3-55-g6feb From f97dc8489d58aef2d038288f9a8bc69f907e17bb Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Tue, 22 Mar 2022 19:21:58 +0100 Subject: fix(docs) fix html linter issues in the docs (#358) --- doc/dns.html | 78 ++++++------- doc/ftp.html | 122 ++++++++++---------- doc/http.html | 142 +++++++++++------------ doc/index.html | 140 +++++++++++------------ doc/ltn12.html | 200 ++++++++++++++++----------------- doc/mime.html | 302 ++++++++++++++++++++++++------------------------- doc/reference.html | 22 ++-- doc/smtp.html | 191 +++++++++++++++---------------- doc/socket.html | 256 ++++++++++++++++++++--------------------- doc/tcp.html | 325 +++++++++++++++++++++++++++-------------------------- doc/udp.html | 94 ++++++++-------- 11 files changed, 938 insertions(+), 934 deletions(-) (limited to 'doc/http.html') diff --git a/doc/dns.html b/doc/dns.html index c4a0472..56ce3ba 100644 --- a/doc/dns.html +++ b/doc/dns.html @@ -1,4 +1,4 @@ - @@ -13,22 +13,22 @@ -
    +

    - -
    -LuaSocket +
    +LuaSocket
    Network support for the Lua language +
    Network support for the Lua language
    -

    +

    home · download · installation · introduction · -reference +reference


    @@ -36,14 +36,14 @@ -

    DNS

    +

    DNS

    -IPv4 name resolution functions -dns.toip +IPv4 name resolution functions +dns.toip and -dns.tohostname -return all information obtained from +dns.tohostname +return all information obtained from the resolver in a table of the form:

    @@ -60,10 +60,10 @@ Note that the alias list can be empty.

    -The more general name resolution function -dns.getaddrinfo, which +The more general name resolution function +dns.getaddrinfo, which supports both IPv6 and IPv4, -returns all information obtained from +returns all information obtained from the resolver in a table of the form:

    @@ -88,82 +88,82 @@ addresses, and "inet6" for IPv6 addresses. -

    +

    socket.dns.getaddrinfo(address)

    -

    -Converts from host name to address. +

    +Converts from host name to address.

    -

    -Address can be an IPv4 or IPv6 address or host name. +

    +Address can be an IPv4 or IPv6 address or host name.

    -

    +

    The function returns a table with all information returned by the resolver. In case of error, the function returns nil -followed by an error message. +followed by an error message.

    -

    +

    socket.dns.gethostname()

    -

    -Returns the standard host name for the machine as a string. +

    +Returns the standard host name for the machine as a string.

    -

    +

    socket.dns.tohostname(address)

    -

    +

    Converts from IPv4 address to host name.

    -

    -Address can be an IP address or host name. +

    +Address can be an IP address or host name.

    -

    +

    The function returns a string with the canonic host name of the given address, followed by a table with all information returned by the resolver. In case of error, the function returns nil -followed by an error message. +followed by an error message.

    -

    +

    socket.dns.toip(address)

    -

    +

    Converts from host name to IPv4 address.

    -

    -Address can be an IP address or host name. +

    +Address can be an IP address or host name.

    -

    +

    Returns a string with the first IP address found for address, followed by a table with all information returned by the resolver. In case of error, the function returns nil followed by an error -message. +message.

    -
  • + -

    -The LuaSocket send function does not care or interpret the -headers you send, but it gives you full control over what is sent and +

    +The LuaSocket send function does not care or interpret the +headers you send, but it gives you full control over what is sent and to whom it is sent:

    • If someone is to receive the message, the e-mail address has to be in the recipient list. This is the only parameter that controls who -gets a copy of the message; -
    • If there are multiple recipients, none of them will automatically +gets a copy of the message;
    • +
    • If there are multiple recipients, none of them will automatically know that someone else got that message. That is, the default behavior is -similar to the Bcc field of popular e-mail clients; +similar to the Bcc field of popular e-mail clients;
    • It is up to you to add the To header with the list of primary -recipients so that other recipients can see it; -
    • It is also up to you to add the Cc header with the -list of additional recipients so that everyone else sees it; -
    • Adding a header Bcc is nonsense, unless it is +recipients so that other recipients can see it;
    • +
    • It is also up to you to add the Cc header with the +list of additional recipients so that everyone else sees it;
    • +
    • Adding a header Bcc is nonsense, unless it is empty. Otherwise, everyone receiving the message will see it and that is -exactly what you don't want to happen! +exactly what you don't want to happen!
    -

    -I hope this clarifies the issue. Otherwise, please refer to +

    +I hope this clarifies the issue. Otherwise, please refer to RFC 2821 and RFC 2822.

    -
    +
     -- load the smtp support
     local smtp = require("socket.smtp")
     
     -- Connects to server "localhost" and sends a message to users
    --- "fulano@example.com",  "beltrano@example.com", 
    +-- "fulano@example.com",  "beltrano@example.com",
     -- and "sicrano@example.com".
     -- Note that "fulano" is the primary recipient, "beltrano" receives a
     -- carbon copy and neither of them knows that "sicrano" received a blind
    @@ -388,17 +389,17 @@ mesgt = {
     
     r, e = smtp.send{
       from = from,
    -  rcpt = rcpt, 
    +  rcpt = rcpt,
       source = smtp.message(mesgt)
     }
     
    -