www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - (Phobos - SocketStream) Am I doing something wrong or is this a bug?

While trying to learn sockets in Phobos, I ran into a problem.  I was trying to
download the google logo via an HTTP GET.  when I do a socketStream.read, the
returned "bytes read" value indicates that less bytes were read in than were
available (4097 bytes to be exact).  The google logo is 8558 bytes in size as
indicated by the HTTP headers received.  Here is my code:

module HttpManager;

import std.stream;
import std.stdio;
import std.socket;
import std.socketstream;

import std.string;

int main()
	char[] line;
	ubyte[] data = new ubyte[8558];
	uint num = 0;

	TcpSocket socket = new TcpSocket(new InternetAddress("www.google.com", 80));

	socket.send("GET /intl/en_ALL/images/logo.gif HTTP/1.0\r\n\r\n");

	SocketStream socketStream = new SocketStream(socket);
		line = socketStream.readLine();

		if (line=="")

		writef("%s\n", line);

	num = socketStream.read(data);

	writef("\n\nNum: %d\n\n", num);

	File file = new File("logo.gif", FileMode.Out);

	return 0;

The console output is:

	HTTP/1.1 200 OK
	Content-Type: image/gif
	Last-Modified: Wed, 07 Jun 2006 19:38:24 GMT
	Date: Tue, 03 Nov 2009 13:04:57 GMT
	Expires: Wed, 03 Nov 2010 13:04:57 GMT
	X-Content-Type-Options: nosniff
	Server: gws
	Content-Length: 8558
	Cache-Control: public, max-age=31536000
	Age: 28322
	X-XSS-Protection: 0

	Num: 4097

I am using dmd v1.050 with dsss v0.78

Sorry if this is a stupid question.  Any help would be very appreciated :)

Nov 03 2009