Anything like javax.servlet.http.HttpServletRequest?

243 views
Skip to first unread message

Yan Yan

unread,
May 20, 2016, 8:38:27 AM5/20/16
to grpc.io
Anything like javax.servlet.http.HttpServletRequest?
Can the client and server set session attributes?


Eric Anderson

unread,
May 20, 2016, 11:58:57 AM5/20/16
to Yan Yan, grpc.io
On Fri, May 20, 2016 at 5:38 AM, Yan Yan <lamh...@gmail.com> wrote:
Anything like javax.servlet.http.HttpServletRequest?

I'm not sure I follow what the question is. The closest we have is ServerCallStreamObserver or ServerCall (depending on what layer of the stack you're in).

Can the client and server set session attributes?

There are no sessions in gRPC. So no. 

Yan Yan

unread,
May 20, 2016, 9:18:27 PM5/20/16
to grpc.io, lamh...@gmail.com
Thanks for your reply. It may not be a session attribute. Can I set channel attributes? Can I make something available for all subsequent calls going thru the same channel without repeating it in the request message?

When the client is initiating the connection, can I insert any key-value pairs for the server to retrieve during incoming calls? Can the server retrieve those key-value pairs from the context argument of the ListFeatures method? That key-value pair should exist outside the request message Rectangle? Thx.


def ListFeatures(self, request, context):

def run():
  channel = implementations.insecure_channel('localhost', 50051)
  stub = route_guide_pb2.beta_create_RouteGuide_stub(channel)

Eric Anderson

unread,
May 21, 2016, 11:15:30 AM5/21/16
to Yan Yan, grpc.io
On Fri, May 20, 2016 at 6:18 PM, Yan Yan <lamh...@gmail.com> wrote:
Thanks for your reply. It may not be a session attribute. Can I set channel attributes? Can I make something available for all subsequent calls going thru the same channel without repeating it in the request message?

No. We're purposefully discouraging per-connection state management in applications. It is brittle and prone to making false assumptions. Only transport-level security works on a per-connection basis (like in TLS mutual authentication).

If you want it just for convenience, some languages are gaining interceptors (with Java and Go already having them). You could have an interceptor that adds the information each request.

Yan Yan

unread,
May 21, 2016, 7:50:42 PM5/21/16
to grpc.io, lamh...@gmail.com

Eric Anderson

unread,
May 24, 2016, 1:26:59 PM5/24/16
to Yan Yan, grpc.io
On Sat, May 21, 2016 at 4:50 PM, Yan Yan <lamh...@gmail.com> wrote:
Do interceptors work like javax.servlet.Filter?

Yes. The two serve a similar purpose and behave similarly. There is more wrapping that goes on with Java's interceptors, just given the differences in request/response API.

Do I get interceptors in python and C++?

As of yet, no. It seems likely to happen eventually, but it's not there now.

Yan Yan

unread,
May 24, 2016, 7:27:27 PM5/24/16
to grpc.io, lamh...@gmail.com
ty
Reply all
Reply to author
Forward
0 new messages