Rob, I understand your requirement. There is a related RFE to cover this: http://restlet.tigris.org/issues/show_bug.cgi?id=157 IMO, the best way to optimize these calls would be at the Component Context's dispatcher level.
Best regards, Jerome _____ De : Rob Heittman [mailto:[EMAIL PROTECTED] Envoyé : samedi 18 août 2007 21:54 À : [email protected] Objet : Shortcut local traffic between Restlet HTTP clients and servers I have a number of services that expose their API via HTTP. These services are independent, but interoperate; thus, a Content Service might interrogate a User Service to determine profile information for a user. The services might be on the same host, or they might be on distributed hosts. Services using compatible APIs might not even have the same implementation environment (e.g. an underlying ASP, PHP or Rails implementation). The services are not bound to each other in a fixed way, and any given service might have cause to interact with both local and remote services. Thus, sometimes the content service on http://hostedhost/content needs to interrogate http://hostedhost/usrv (part of the same Component). But at other times it might need to interrogate http://clienthost/usrv (an instance running on a different host across the public Internet). In the event that both the client and server service for a given transaction are both Restlets in the same Component, I would like the ability to shortcut the serialization, deserialization, and network overhead of the protocol and pass the Request from the client directly to the local Server and get the Response back, in-VM. This allows the same code base to be highly efficient in a small monolithic installation (e.g. a portable application), and highly versatile in a distributed environment. Ideally, I would prefer that this happened transparently based on the definition of the VirtualHosts in the current component; a Client(Protocol.HTTP) asked to make a request from http://hostedhost to http://hostedhost would automatically skip the network layer and forward the request internally. Short Term: Is this the best way to implement this myself: create a new extension along the lines of com.noelios.restlet.ext.httpclient_3.1, which would attempt to detect the "locality" condition, forward via HTTP when needed, and instead poke Requests at the current component's ServerRouter when possible? Any obvious thread safety or other issues I should concern myself with? Long Term: Does anyone other than me perceive this as valuable behavior? Conversely, any major inherent problems? Should an option to behave this way be a part of the reference implementation, even as an extension? - Rob

