diff --git a/samples/htmlget.d b/samples/htmlget.d index 3e30aded9a..8b15ed600a 100644 --- a/samples/htmlget.d +++ b/samples/htmlget.d @@ -6,10 +6,10 @@ This code has no warranties and is provided 'as-is'. */ -// debug = HTMLGET; +debug = HTMLGET; -import std.string, std.conv, std.stream, std.stdio; -import std.socket, std.socketstream; +import std.string, std.conv, std.stdio; +import std.socket; int main(string[] args) { @@ -67,7 +67,6 @@ int main(string[] args) Socket sock = new TcpSocket(new InternetAddress(domain, port)); scope(exit) sock.close(); - Stream ss = new SocketStream(sock); debug (HTMLGET) writefln("Connected! Requesting URL \"%s\"...", url); @@ -75,18 +74,27 @@ int main(string[] args) if (port != 80) domain = domain ~ ":" ~ to!string(port); - ss.writeString("GET " ~ url ~ " HTTP/1.0\r\n" - "Host: " ~ domain ~ "\r\n" + sock.send("GET " ~ url ~ " HTTP/1.0\r\n" ~ + "Host: " ~ domain ~ "\r\n" ~ "\r\n"); // Skip HTTP header. while (true) { - auto line = ss.readLine(); + char[] line; + char[1] buf; + while(sock.receive(buf)) + { + line ~= buf; + if (buf[0] == '\n') + break; + } if (!line.length) break; + write(line); + enum CONTENT_TYPE_NAME = "Content-Type: "; if (line.length > CONTENT_TYPE_NAME.length && @@ -99,11 +107,5 @@ int main(string[] args) } } - while (!ss.eof()) - { - auto line = ss.readLine(); - writeln(line); - } - return 0; } diff --git a/samples/win32.mak b/samples/win32.mak new file mode 100644 index 0000000000..76b438fc0a --- /dev/null +++ b/samples/win32.mak @@ -0,0 +1,63 @@ + +DMD=..\..\windows\bin\dmd +DFLAGS= + +EXAMPLES = hello d2html dhry pi sieve wc wc2 \ + winsamp dserver mydll htmlget listener + +all: $(EXAMPLES) + +d2html: + $(DMD) d2html $(DFLAGS) + .\d2html.exe d2html.d + +dhry: + $(DMD) dhry $(DFLAGS) + .\dhry.exe + +hello: + $(DMD) hello $(DFLAGS) + .\hello.exe + +htmlget: + $(DMD) htmlget $(DFLAGS) + .\htmlget.exe www.dlang.org/index.html + +listener: + $(DMD) listener $(DFLAGS) + # .\listener.exe + +pi: + $(DMD) pi $(DFLAGS) + .\pi.exe 1000 + +sieve: + $(DMD) sieve $(DFLAGS) + .\sieve.exe + +wc: + $(DMD) wc $(DFLAGS) + .\wc.exe wc.d + +wc2: + $(DMD) wc2 $(DFLAGS) + .\wc2.exe wc2.d + +winsamp: + $(DMD) winsamp $(DFLAGS) gdi32.lib user32.lib winsamp.def + # .\winsamp.exe + +# COM client/server example +dserver: + $(DMD) dserver.d chello.d $(DFLAGS) dserver.def advapi32.lib ole32.lib user32.lib + # dclient will fail unless run with administrator rights + $(DMD) dclient $(DFLAGS) ole32.lib uuid.lib + .\dclient.exe + +mydll: + $(DMD) $(DFLAGS) -ofmydll.dll -L/IMPLIB mydll\mydll.d mydll\dll.d mydll\mydll.def + $(DMD) $(DFLAGS) -ofdlltest.exe -Imydll mydll\test.d mydll.lib + .\dlltest.exe + +clean: + clean.bat diff --git a/win32.mak b/win32.mak index 3c6054f9ad..ef9096d194 100644 --- a/win32.mak +++ b/win32.mak @@ -5,8 +5,15 @@ auto-tester-build: $(MAKE) -f win32.mak auto-tester-build cd .. -auto-tester-test: +auto-tester-test: auto-tester-samples cd test $(MAKE) cd .. +# hard coding gmake here as the auto-tester does +# some patches only to the lines with $(MAKE) above +auto-tester-samples: + cd samples + gmake -f win32.mak DMD=..\src\dmd.exe "DFLAGS=-I..\..\druntime\import -I..\..\phobos" LIB=..\..\phobos + cd .. +