HTTPLoop.RequestProgram.not_query

Eiichiro ITANI <[email protected]>
Newsgroups gmane.comp.lang.pike.user
Organization As a person, No organization
Message-ID <[email protected]>
Hi all.

I wrote simple toy program to see how to use HTTPLoop module.  Reference
saying HTTPLoop as identifier, but I cannot access module by this name.
It looks identifiers are not HTTPLoop and HTTPLoop.RequestProgram but
HTTPAccept and HTTPAccept.prog.  I found this from the example(?) file
"src/modules/HTTPLoop/wwwserver.pike".

Anyway, assuming that HTTPLoop is HTTPAccept, I ran my simple program
attached below, and send request to program like this:

$ echo -e "GET / HTTP/1.0\r\nHost: localhost\r\n\r\n"|nc localhost 8172

With pike8.0 (from Debian official package, v8.0.28), output of sample
says

  not_query -> "/\346"

"not_query" contains extra character at end.  The trailing character
changes upredictable form, it seems overlooking string boundary.

With pike7.8, this problem doesn't occur.  I didn't tested this with
pike8.0 git HEAD version, but tree under HTTPLoop not changed since
v8.0.28.

Is this problem still exists?  If already fixed, I'll wait for update of
debian.  Or should I send bug tracker?


--
  ITANI Eiichiro
simple_example.pike (text/x-pike, 911 B)
#!/usr/bin/pike

#ifndef PORT
#define PORT 8172;
#endif

int port = PORT;

class RequestHandler {
	inherit HTTPAccept.prog;
}
mixed req_handler(object pg) {
	werror("  not_query -> %O\n",pg.not_query);
	string body = "Got request done.\n";
	array(string) head = ({
	                       "HTTP/1.0 200 OK",
	                       "Content-Type: text/plain",
	                       sprintf("Content-Length: %d",sizeof(body)),
	                       "",
	});
	string resp_header = map(head,`+,"\r\n") * "";

	pg->reply(resp_header+body);
}

int main(int argc, array(string) argv) {
	Stdio.Port lport = Stdio.Port();
	mixed rb = lport->bind(port);
	if (! rb ) {
		werror("Can't bind port %d(%O)\n",port,rb);
		return 1;
	}
	int pid = getpid();
	werror("Port: %O(%d)\n",lport,pid);

	if (HTTPAccept.Loop(lport, RequestHandler, req_handler, 0, 0, 20, 0))
		return -1;
	werror("Failed or exited event loop\n");
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.