Author Topic: HTTPObject - multiple GET parameters  (Read 1303 times)

I am having trouble, when I try using multiple parameters, such as this:
CMD=lol&val=Jesus

The webserver tries to treat "CMD" as containing "lol&val=Jesus". Any help?

Since no one else has given an answer I might as well give a guess.

Try using @ instead.

Inb4noandlongexplanation.

new HTTPObject(KHT); KHT.get("google.com:80", "/", "param1=answer1&param2=answer2");


Investigating the packet:
GET /?parama1=answer1l%26param2=answer2 HTTP/1.1
Host: google.com


So basically it's screwing up the &

I am having trouble, when I try using multiple parameters, such as this:
CMD=lol&val=Jesus

The webserver tries to treat "CMD" as containing "lol&val=Jesus". Any help?

By the title - "HTTPObject - multiple GET parameters" - I assume that you want to use get data, however get data is passed to the server entirely encoded in the url that you request.

Post data seems similar to what you are describing.

To prove my point, I created two examples, the first, using get data, the second, using post data:

The first example's html form.
Code: [Select]
<html>
<body>
<form name="input" action="http://127.0.0.1/doesNotExist.php" method="get">
<input type="text" name="var1" value="asdf1" />
<input type="text" name="var2" value="asdf2" />
<input type="submit" />
</form>
</body>
<html>

The first examples's http header. (With the user agent foobared.)
Code: [Select]
GET /doesNotExist.php?var1=asdf1&var2=asdf2 HTTP/1.1
Host: 127.0.0.1
User-Agent: foo
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive


The second example's html form. (Same as the first one but using POST instead of GET as a method of sending data to the server.)
Code: [Select]
<html>
<body>
<form name="input" action="http://127.0.0.1/doesNotExist.php" method="post">
<input type="text" name="var1" value="asdf1" />
<input type="text" name="var2" value="asdf2" />
<input type="submit" />
</form>
</body>
<html>

The second examples's http header. (With the user agent foobared.)
Code: [Select]
POST /doesNotExist.php HTTP/1.1
Host: 127.0.0.1
User-Agent: foo
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 21

var1=asdf1&var2=asdf2

I think you might be under the impression that you need to use "CMD=" because I think I remember from when I read it that RTB2 (and possibly 3, I still have yet to read it) uses "c" as one of (or rather, their first) variable that is passed. This variable represents a command, and in the scripts, is usually referred to as "%cmd".

Here is an example of a header sent by RTB2 with the a few values (that are useless to a reader anyway) foobared.
Code: [Select]
POST /blockland/rtbClientAuth.php HTTP/1.1
Host: 127.0.0.1
User-Agent: Torque/1.0
Content-Type: application/x-www-form-urlencoded
Content-Length: 160

c=AUTH&n=bob%26rob&arg1=Not%20on%20a%20Server&arg2=foo&arg3=2.03&arg4=foo&arg5=&arg6=&arg7=&arg8=&arg9=&arg10=&PHPSESSID=foo

I also push the case that your tcpObject::get() method may be the problem because in a default install of BL, there is no such method, look at this log excerpt from a fresh install of BL made just for this purpose.

Code: [Select]
==>new tcpObject(doIHaveAGetMethod);
==>doIHaveAGetMethod.dump();
Member Fields:
Tagged Fields:
Methods:
  connect() - (string addr)Connect to the given address.
  delete() - obj.delete()
  disconnect() - Disconnect from whatever we're connected to, if anything.
  dump() - obj.dump()
  getClassName() - obj.getClassName()
  getGroup() - obj.getGroup()
  getId() - obj.getId()
  getName() - obj.getName()
  getType() - obj.getType()
  listen() - (int port)Start listening on the specified ports for connections.
  save() - obj.save(fileName, <selectedOnly>)
  saveBufferToFile() - (string filename)Save the data recieved since isBinary(true) to a file.
  schedule() - object.schedule(time, command, <arg1...argN>);
  send() - (...)Parameters are transmitted as strings, one at a time.
  setBinary() - (bool true/false)Starts to accumulate recived data into a buffer. This can be saved with saveBufferToFile
  setBinarySize() - (int filesize)Starts to accumulate recived data into a buffer and initialises an array of size filesize.
-NEWLINE SO AS NOT TO STRETCH THE FORUM PAGE- This can be saved with saveBufferToFile
  setName() - obj.setName(newName)

Warning - while you were typing a new reply has been posted. You may wish to review your post.
« Last Edit: September 14, 2009, 07:03:10 PM by BobAndRob »

I also push the case that your tcpObject::get() method may be the problem because in a default install of BL, there is no such method, look at this log excerpt from a fresh install of BL made just for this purpose.
The TCPObject class is a simple streaming socket. The HTTPObject is a HTTP connection (which uses TCP) and only it has the get and post methods.

The TCPObject class is a simple streaming socket. The HTTPObject is a HTTP connection (which uses TCP) and only it has the get and post methods.
Ummm.... oh. Thanks for that clarification.

I didn't know it existed and misread his post, so much for all the time I spent writing my response.