HTTP server.ServerCommandGet

HTTP server.ServerCommandGet

Post by Paul » Sat, 08 Jan 2005 02:44:14


Hi,

I have a strange behavior in the HTTPserver.ServerCommandGet procedure

I try to filter out a command with optional parameters which has been
submitted to requestinfo.Document.
I am using this for all the commands I submit with the HTTP.Get command and
it works fine.
A strange happens when the 'params' I send is a directory.

If send a command f.i. = 'Gfiles test', then the result on the server is:
Scmd : Gfiles
Params: test

When I send the command as 'GFiles C:\Windows', then '\' becomes '/';
Scmd : GFiles
Params: C:/Windows.
The second time I send the same command , The params become
Params: C:/GFiles C/Windows
The third time
Params: C:/GFiles C:/GFiles C/Windows

the HTTPserver gets confused.

Is there a workaround for this?
I am using indy9

This is the code in HTTPserver.ServerCommandGet
Params:= ARequestInfo.Document;
T:= pos(' ',Params);
if T=0 then Scmd:= Params
else
begin
Scmd:= Copy(Params, 1, T-1); //Command string
Params:= Copy(Params, T+1, Length(Params)-T); //parameters string
end;


Paul
 
 
 

HTTP server.ServerCommandGet

Post by Team » Sat, 08 Jan 2005 03:54:37


Please show what your actual request URLs look like.


As well it should. If your parameters are in the URL itself, then all '\'
must be converted to '/'. If you do not want that, then your '\' character
must be encoded as '%5C' instead, ie:

GFiles C%3A%5CWindows

You should also encode spaces as well:

GFiles%20C%3A%5CWindows


You did not show your client code that is sending the requests.


Parameter are not supposed to be placed in the document to begin with. You
should be using a '?' in your URLs, ie:

http://host/GFiles?c%3A%5Cwindows

That way, your Document is always 'GFiles' and the parameters are always in
the QueryParams. That is how HTTP ius designed to be used. You are not
using it properly in the first place, so you do not get the correct results.


Gambit

 
 
 

HTTP server.ServerCommandGet

Post by Paul » Sat, 08 Jan 2005 07:52:55

Hi Remy

character

This doesn't work also.
I replace the '/' back into '\' by code now.

You
in
results.

Placing a '?' works fine.

Also, I find it very frustrating to find out such basic things this way.
Shouldn't all this be documented in a manual?
I have the manual 'Indy in depth', but it's a waste of money, especially on
the HTTP part.
Are there any good examples where beginners like me can learn from?
After all, a few good examples with some explanation tell more than a book.
Maybe ICS is an option, at least, it has a lot more examples than Indy has.


Paul
 
 
 

HTTP server.ServerCommandGet

Post by Team » Sat, 08 Jan 2005 08:12:06


Again, I ask you to please show your actual code and URLs. It keeps
sounding like you are misusing the HTTP protocol to begin with.


You are trying to write a server without having knowledge of how the
protocol itself is designed to work in the first place. I suggest you read
RFCs 1945 and 2616 before you go any further.

has.

You are misusing the HTTP protocol to begin with. You are going to have
problems regardless of the component used until you start using protocol the
way it was meant to be used.


Gambit
 
 
 

HTTP server.ServerCommandGet

Post by Paul » Sat, 08 Jan 2005 18:40:01


read

I am not interested to write a complete HTTP server .
I am an electronics engeneer and I use the internet for one single purpose
only
and that is control machines remotely.
So the only thing I need is to send strings and streams between 2 computers.
Normally, TCP would be the right choise, but the use of firewalls force me
to step to HTTP. Therefore, I basically need 2 HTTP clients to communicate
with each other to pass the ISP also, since they block a HTTPserver on port
80,
unless you pay for a static IP-address.
Therefore, I need some kind op HTTP-server relay to pass the commands
between the 2 clients.


Paul
 
 
 

HTTP server.ServerCommandGet

Post by Team » Sun, 09 Jan 2005 04:01:45


Even with a minimal server implementation, you should still rad up on how
the HTTP protocol actually works.


Even with HTTP, you are still using TCP.


Then don't use port 80. Use a non-sandard port instead. ISPs can't block
all ports. Nothing would be able to run at all if they did that.


Gambit
 
 
 

HTTP server.ServerCommandGet

Post by Paul » Sun, 09 Jan 2005 04:15:06


I am working on that, but knowing everyting about RFC2616
takes a lot of time


Sure , my ISP allows a HTTPserver above port 1023,
but the clients firewalls allow only HTTP on port 80 or SSL on port 443
So , the only option I have is to connect 2 HTTPclients throug a
'HTTPserver relay'
to pass the commands to the 2 HTTPclients.


Paul
 
 
 

HTTP server.ServerCommandGet

Post by Team » Sun, 09 Jan 2005 06:22:04


Then you will just have to talk to your ISP about opening up port 80.


What does that have to do with anything? Your original question was asking
about processing commands. Not relaying the commands. I asked you to
please show what your actual HTTP requests look like, and you never did so.
Everything you have described so far sounds like you are misusing the HTTP
protocol, but you have not yet provided any of the details I asked you for.


Gambit