diff --git a/config b/config index f26b12e..3954974 100644 --- a/config +++ b/config @@ -37,20 +37,20 @@ INSTALL_EXEC=cp # Compiler and linker settings # for Mac OS X # -CC=gcc -DEF=-DLUASOCKET_DEBUG -DUNIX_HAS_SUN_LEN -CFLAGS= $(LUAINC) -I$(COMPAT) $(DEF) -pedantic -Wall -O2 -fno-common -LDFLAGS=-bundle -undefined dynamic_lookup -LD=export MACOSX_DEPLOYMENT_TARGET="10.3"; gcc +#CC=gcc +#DEF=-DLUASOCKET_DEBUG -DUNIX_HAS_SUN_LEN +#CFLAGS= $(LUAINC) -I$(COMPAT) $(DEF) -pedantic -Wall -O2 -fno-common +#LDFLAGS=-bundle -undefined dynamic_lookup +#LD=export MACOSX_DEPLOYMENT_TARGET="10.3"; gcc #------ # Compiler and linker settings # for Linux -#CC=gcc -#DEF=-DLUASOCKET_DEBUG -#CFLAGS= $(LUAINC) -I$(COMPAT) $(DEF) -pedantic -Wall -O2 -fpic -#LDFLAGS=-O -shared -#LD=gcc +CC=gcc +DEF=-DLUASOCKET_DEBUG +CFLAGS= $(LUAINC) -I$(COMPAT) $(DEF) -pedantic -Wall -O2 -fpic +LDFLAGS=-O -shared +LD=gcc #------ # End of makefile configuration diff --git a/src/http.lua b/src/http.lua index e002a8c..bfa0345 100644 --- a/src/http.lua +++ b/src/http.lua @@ -226,9 +226,9 @@ local default = { local function adjustrequest(reqt) -- parse url if provided local nreqt = reqt.url and url.parse(reqt.url, default) or {} - local t = url.parse(reqt.url, default) -- explicit components override url for i,v in base.pairs(reqt) do nreqt[i] = v end + if nreqt.port == "" then nreqt.port = 80 end socket.try(nreqt.host, "invalid host '" .. base.tostring(nreqt.host) .. "'") -- compute uri if user hasn't overriden nreqt.uri = reqt.uri or adjusturi(nreqt) diff --git a/test/auth/.htaccess b/test/auth/.htaccess index 31e1123..b9f100e 100644 --- a/test/auth/.htaccess +++ b/test/auth/.htaccess @@ -1,4 +1,4 @@ AuthName "Test Realm" AuthType Basic -AuthUserFile /Users/diego/tec/luasocket/test/auth/.htpasswd +AuthUserFile /home/diego/tec/luasocket/test/auth/.htpasswd require valid-user diff --git a/test/auth/.htpasswd b/test/auth/.htpasswd index 824bac9..fd9002b 100644 --- a/test/auth/.htpasswd +++ b/test/auth/.htpasswd @@ -1 +1 @@ -luasocket:JFMQjUyOPu3yk +luasocket:l8n2npozPB.sQ diff --git a/test/httptest.lua b/test/httptest.lua index c05b4cc..92528b2 100644 --- a/test/httptest.lua +++ b/test/httptest.lua @@ -22,7 +22,8 @@ http.TIMEOUT = 10 local t = socket.gettime() -host = host or "diego.student.princeton.edu" +--host = host or "diego.student.princeton.edu" +host = host or "dell-diego" proxy = proxy or "http://localhost:3128" prefix = prefix or "/luasocket-test" cgiprefix = cgiprefix or "/luasocket-test-cgi" @@ -125,6 +126,20 @@ assert(r == nil and e == re, tostring(r) ..", " .. tostring(re) .. " vs " .. tostring(e)) print("ok") +io.write("testing invalid empty port: ") +request = { + url = "http://" .. host .. ":" .. prefix .. "/index.html" +} +expect = { + body = index, + code = 200 +} +ignore = { + status = 1, + headers = 1 +} +check_request(request, expect, ignore) + ------------------------------------------------------------------------ io.write("testing post method: ") -- wanted to test chunked post, but apache doesn't support it... diff --git a/test/testmesg.lua b/test/testmesg.lua index 5bec026..ab85c93 100644 --- a/test/testmesg.lua +++ b/test/testmesg.lua @@ -83,9 +83,10 @@ r, e = smtp.send{ "" }, from = "", source = ltn12.source.chain(source, filter), - --server = "mail.cs.princeton.edu" - server = "localhost", - port = 2525 + server = "mail.cs.princeton.edu", + --server = "localhost", + --port = 2525 + port = 25 } print(r, e)