From: jeljer te Wies Date: 2010-08-28T17:34:53+09:00 Subject: Re: how to detect used protocol (SOAP, JSON, XML etc.) Ehm guys. Why are you all commenting on a 6 months old post ;) I solved the problem already!! I choose to use the TUple Space architecture. Then i can send just ruby objects over tcp ! (very nice) thanxs for the replies though :P Brian Candler wrote: > Allan Bonadio wrote: >> But of course you can legally stick in spaces so you could use this >> regex: >> if (datastring..search(/^\s*[\[|\{]/) >= 0) .... > > Note that even when fixed, that regexp would match > > [hello] > > > In Ruby you have to use \A to match start of string. > > Anyway, I'd say this sort of attempted format detection is fairly > pointless at best, and dangerous at worst. Better to get the client to > tell you explicitly what it has sent. In the case of HTTP, this could be > via Content-Type: header or via the URL endpoint, e.g. /foo.xml. In the > case of a raw TCP protocol then you can use different port numbers. -- Posted via http://www.ruby-forum.com/.