You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "dave irving (JIRA)" <ji...@apache.org> on 2010/02/19 10:13:27 UTC

[jira] Created: (HTTPCLIENT-915) Provide a clean mechanism to attatch user define attributes to connections

Provide a clean mechanism to attatch user define attributes to connections
--------------------------------------------------------------------------

                 Key: HTTPCLIENT-915
                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-915
             Project: HttpComponents HttpClient
          Issue Type: New Feature
          Components: HttpConn
            Reporter: dave irving
            Priority: Minor


It would be nice to have a way to attach user defined attributes to a connection.
Ideally it'd be nice if such support could be added to HttpClientConnection, but understandably this may not be possible due to back-compatibility issues.
So, we could have something like HttpConnectionContext perhaps (or similar) with:

HttpConnectionContext#setAttribute(String name, Object value)
Object HttpConnectionContext#getAttribute(String name)

This would be made available in the HttpContext of a request (like the connection is today):

HttpConnectionContext connectionContext = (HttpConnectionContext) httpContext.getAttribute(ExecutionContext.HTTP_CONNECTION_CONTEXT);

This would make a few things much cleaner to implement than they are today: The most obvious being my current use case of wanting connection isolated cookies.

Currently to achieve this goal we need to provide custom client connection + connection operator + connection manager implementations. Then there is no clean way to currently obtain the actual connection instance created by a custom operator in the HttpContext: As it's wrapped by the connection pool and #getWrappedConnection is protected - so we need to resort to reflection in interceptors.

Providing a clean mechanism for attaching user defined attributes to a connection instance as described above would make such implementations far far simpler.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] Commented: (HTTPCLIENT-915) Provide a clean mechanism to attatch user define attributes to connections

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCLIENT-915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12835710#action_12835710 ] 

Oleg Kalnichevski commented on HTTPCLIENT-915:
----------------------------------------------

I also see potential issues with the connection bound state. HTTP connections are meant to be stateless. They can be pooled and re-used within a completely different user / security context. If a connection contains attributes that are user specific / security sensitive, all sorts of issues may arise, very much like with thread local variables. However, you already have this problem with NTLM and SSL connections anyway. So, this feature should be used with caution, but we should still provide support for it.

Oleg

> Provide a clean mechanism to attatch user define attributes to connections
> --------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-915
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-915
>             Project: HttpComponents HttpClient
>          Issue Type: New Feature
>          Components: HttpConn
>    Affects Versions: 4.0.1
>            Reporter: dave irving
>            Priority: Minor
>             Fix For: 4.1 Alpha2
>
>
> It would be nice to have a way to attach user defined attributes to a connection.
> Ideally it'd be nice if such support could be added to HttpClientConnection, but understandably this may not be possible due to back-compatibility issues.
> So, we could have something like HttpConnectionContext perhaps (or similar) with:
> HttpConnectionContext#setAttribute(String name, Object value)
> Object HttpConnectionContext#getAttribute(String name)
> This would be made available in the HttpContext of a request (like the connection is today):
> HttpConnectionContext connectionContext = (HttpConnectionContext) httpContext.getAttribute(ExecutionContext.HTTP_CONNECTION_CONTEXT);
> This would make a few things much cleaner to implement than they are today: The most obvious being my current use case of wanting connection isolated cookies.
> Currently to achieve this goal we need to provide custom client connection + connection operator + connection manager implementations. Then there is no clean way to currently obtain the actual connection instance created by a custom operator in the HttpContext: As it's wrapped by the connection pool and #getWrappedConnection is protected - so we need to resort to reflection in interceptors.
> Providing a clean mechanism for attaching user defined attributes to a connection instance as described above would make such implementations far far simpler.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] Commented: (HTTPCLIENT-915) Provide a clean mechanism to attatch user define attributes to connections

Posted by "dave irving (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCLIENT-915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12835735#action_12835735 ] 

dave irving commented on HTTPCLIENT-915:
----------------------------------------

(Non binding) +1 from me. Looks perfect. 

Thanks so much for looking in to this so quickly.

Dave

> Provide a clean mechanism to attatch user define attributes to connections
> --------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-915
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-915
>             Project: HttpComponents HttpClient
>          Issue Type: New Feature
>          Components: HttpConn
>    Affects Versions: 4.0.1
>            Reporter: dave irving
>            Priority: Minor
>             Fix For: 4.1 Alpha2
>
>         Attachments: HTTPCLIENT-915-take1.patch
>
>
> It would be nice to have a way to attach user defined attributes to a connection.
> Ideally it'd be nice if such support could be added to HttpClientConnection, but understandably this may not be possible due to back-compatibility issues.
> So, we could have something like HttpConnectionContext perhaps (or similar) with:
> HttpConnectionContext#setAttribute(String name, Object value)
> Object HttpConnectionContext#getAttribute(String name)
> This would be made available in the HttpContext of a request (like the connection is today):
> HttpConnectionContext connectionContext = (HttpConnectionContext) httpContext.getAttribute(ExecutionContext.HTTP_CONNECTION_CONTEXT);
> This would make a few things much cleaner to implement than they are today: The most obvious being my current use case of wanting connection isolated cookies.
> Currently to achieve this goal we need to provide custom client connection + connection operator + connection manager implementations. Then there is no clean way to currently obtain the actual connection instance created by a custom operator in the HttpContext: As it's wrapped by the connection pool and #getWrappedConnection is protected - so we need to resort to reflection in interceptors.
> Providing a clean mechanism for attaching user defined attributes to a connection instance as described above would make such implementations far far simpler.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] Updated: (HTTPCLIENT-915) Provide a clean mechanism to attatch user define attributes to connections

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCLIENT-915?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oleg Kalnichevski updated HTTPCLIENT-915:
-----------------------------------------

    Attachment: HTTPCLIENT-915-take1.patch

How about this? I made both DefaultClientConnection and AbstractClientConnAdapter implement HttpContext. This enables connections managed by HttpClient carry additional attributes / state. I reused HttpContext for simplicity.  We could also create a special interface for that.

Please review and let me know what you think.

Oleg

> Provide a clean mechanism to attatch user define attributes to connections
> --------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-915
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-915
>             Project: HttpComponents HttpClient
>          Issue Type: New Feature
>          Components: HttpConn
>    Affects Versions: 4.0.1
>            Reporter: dave irving
>            Priority: Minor
>             Fix For: 4.1 Alpha2
>
>         Attachments: HTTPCLIENT-915-take1.patch
>
>
> It would be nice to have a way to attach user defined attributes to a connection.
> Ideally it'd be nice if such support could be added to HttpClientConnection, but understandably this may not be possible due to back-compatibility issues.
> So, we could have something like HttpConnectionContext perhaps (or similar) with:
> HttpConnectionContext#setAttribute(String name, Object value)
> Object HttpConnectionContext#getAttribute(String name)
> This would be made available in the HttpContext of a request (like the connection is today):
> HttpConnectionContext connectionContext = (HttpConnectionContext) httpContext.getAttribute(ExecutionContext.HTTP_CONNECTION_CONTEXT);
> This would make a few things much cleaner to implement than they are today: The most obvious being my current use case of wanting connection isolated cookies.
> Currently to achieve this goal we need to provide custom client connection + connection operator + connection manager implementations. Then there is no clean way to currently obtain the actual connection instance created by a custom operator in the HttpContext: As it's wrapped by the connection pool and #getWrappedConnection is protected - so we need to resort to reflection in interceptors.
> Providing a clean mechanism for attaching user defined attributes to a connection instance as described above would make such implementations far far simpler.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] Resolved: (HTTPCLIENT-915) Provide a clean mechanism to attatch user define attributes to connections

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCLIENT-915?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oleg Kalnichevski resolved HTTPCLIENT-915.
------------------------------------------

    Resolution: Fixed

Patch checked in.

Oleg

> Provide a clean mechanism to attatch user define attributes to connections
> --------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-915
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-915
>             Project: HttpComponents HttpClient
>          Issue Type: New Feature
>          Components: HttpConn
>    Affects Versions: 4.0.1
>            Reporter: dave irving
>            Priority: Minor
>             Fix For: 4.1 Alpha2
>
>         Attachments: HTTPCLIENT-915-take1.patch
>
>
> It would be nice to have a way to attach user defined attributes to a connection.
> Ideally it'd be nice if such support could be added to HttpClientConnection, but understandably this may not be possible due to back-compatibility issues.
> So, we could have something like HttpConnectionContext perhaps (or similar) with:
> HttpConnectionContext#setAttribute(String name, Object value)
> Object HttpConnectionContext#getAttribute(String name)
> This would be made available in the HttpContext of a request (like the connection is today):
> HttpConnectionContext connectionContext = (HttpConnectionContext) httpContext.getAttribute(ExecutionContext.HTTP_CONNECTION_CONTEXT);
> This would make a few things much cleaner to implement than they are today: The most obvious being my current use case of wanting connection isolated cookies.
> Currently to achieve this goal we need to provide custom client connection + connection operator + connection manager implementations. Then there is no clean way to currently obtain the actual connection instance created by a custom operator in the HttpContext: As it's wrapped by the connection pool and #getWrappedConnection is protected - so we need to resort to reflection in interceptors.
> Providing a clean mechanism for attaching user defined attributes to a connection instance as described above would make such implementations far far simpler.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] Updated: (HTTPCLIENT-915) Provide a clean mechanism to attatch user define attributes to connections

Posted by "dave irving (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCLIENT-915?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

dave irving updated HTTPCLIENT-915:
-----------------------------------

    Affects Version/s: 4.0.1

> Provide a clean mechanism to attatch user define attributes to connections
> --------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-915
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-915
>             Project: HttpComponents HttpClient
>          Issue Type: New Feature
>          Components: HttpConn
>    Affects Versions: 4.0.1
>            Reporter: dave irving
>            Priority: Minor
>
> It would be nice to have a way to attach user defined attributes to a connection.
> Ideally it'd be nice if such support could be added to HttpClientConnection, but understandably this may not be possible due to back-compatibility issues.
> So, we could have something like HttpConnectionContext perhaps (or similar) with:
> HttpConnectionContext#setAttribute(String name, Object value)
> Object HttpConnectionContext#getAttribute(String name)
> This would be made available in the HttpContext of a request (like the connection is today):
> HttpConnectionContext connectionContext = (HttpConnectionContext) httpContext.getAttribute(ExecutionContext.HTTP_CONNECTION_CONTEXT);
> This would make a few things much cleaner to implement than they are today: The most obvious being my current use case of wanting connection isolated cookies.
> Currently to achieve this goal we need to provide custom client connection + connection operator + connection manager implementations. Then there is no clean way to currently obtain the actual connection instance created by a custom operator in the HttpContext: As it's wrapped by the connection pool and #getWrappedConnection is protected - so we need to resort to reflection in interceptors.
> Providing a clean mechanism for attaching user defined attributes to a connection instance as described above would make such implementations far far simpler.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] Commented: (HTTPCLIENT-915) Provide a clean mechanism to attatch user define attributes to connections

Posted by "dave irving (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCLIENT-915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12835696#action_12835696 ] 

dave irving commented on HTTPCLIENT-915:
----------------------------------------

> I think a simple Object is enough. If you need name/value pairs you can 
> store a Map there. Access to the object should be synchronized to or use a volatile field.

I disagree... Unfortunately this introduces coupling between disparate clients.
What happens if I write a "CookiePerConnectionInterceptor" which wants to put a CookieStore in the connection.

Some other interceptor (written by someone else / another project etc) decides that It would like to put a Map of name values pairs in instead.

Oops - now the two can't work together.

The motivation for using an attribute based approach is that it's easy to scope your usage of it.

> Provide a clean mechanism to attatch user define attributes to connections
> --------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-915
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-915
>             Project: HttpComponents HttpClient
>          Issue Type: New Feature
>          Components: HttpConn
>    Affects Versions: 4.0.1
>            Reporter: dave irving
>            Priority: Minor
>             Fix For: 4.1 Alpha2
>
>
> It would be nice to have a way to attach user defined attributes to a connection.
> Ideally it'd be nice if such support could be added to HttpClientConnection, but understandably this may not be possible due to back-compatibility issues.
> So, we could have something like HttpConnectionContext perhaps (or similar) with:
> HttpConnectionContext#setAttribute(String name, Object value)
> Object HttpConnectionContext#getAttribute(String name)
> This would be made available in the HttpContext of a request (like the connection is today):
> HttpConnectionContext connectionContext = (HttpConnectionContext) httpContext.getAttribute(ExecutionContext.HTTP_CONNECTION_CONTEXT);
> This would make a few things much cleaner to implement than they are today: The most obvious being my current use case of wanting connection isolated cookies.
> Currently to achieve this goal we need to provide custom client connection + connection operator + connection manager implementations. Then there is no clean way to currently obtain the actual connection instance created by a custom operator in the HttpContext: As it's wrapped by the connection pool and #getWrappedConnection is protected - so we need to resort to reflection in interceptors.
> Providing a clean mechanism for attaching user defined attributes to a connection instance as described above would make such implementations far far simpler.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] Issue Comment Edited: (HTTPCLIENT-915) Provide a clean mechanism to attatch user define attributes to connections

Posted by "dave irving (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCLIENT-915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12835696#action_12835696 ] 

dave irving edited comment on HTTPCLIENT-915 at 2/19/10 11:05 AM:
------------------------------------------------------------------

> I think a simple Object is enough. If you need name/value pairs you can 
> store a Map there. 

I disagree... Unfortunately this introduces coupling between disparate clients.
What happens if I write a "CookiePerConnectionInterceptor" which wants to put a CookieStore in the connection.

Some other interceptor (written by someone else / another project etc) decides that It would like to put a Map of name values pairs in instead.

Oops - now the two can't work together.

The motivation for using an attribute based approach is that it's easy to scope your usage of it.

      was (Author: irvingd):
    > I think a simple Object is enough. If you need name/value pairs you can 
> store a Map there. Access to the object should be synchronized to or use a volatile field.

I disagree... Unfortunately this introduces coupling between disparate clients.
What happens if I write a "CookiePerConnectionInterceptor" which wants to put a CookieStore in the connection.

Some other interceptor (written by someone else / another project etc) decides that It would like to put a Map of name values pairs in instead.

Oops - now the two can't work together.

The motivation for using an attribute based approach is that it's easy to scope your usage of it.
  
> Provide a clean mechanism to attatch user define attributes to connections
> --------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-915
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-915
>             Project: HttpComponents HttpClient
>          Issue Type: New Feature
>          Components: HttpConn
>    Affects Versions: 4.0.1
>            Reporter: dave irving
>            Priority: Minor
>             Fix For: 4.1 Alpha2
>
>
> It would be nice to have a way to attach user defined attributes to a connection.
> Ideally it'd be nice if such support could be added to HttpClientConnection, but understandably this may not be possible due to back-compatibility issues.
> So, we could have something like HttpConnectionContext perhaps (or similar) with:
> HttpConnectionContext#setAttribute(String name, Object value)
> Object HttpConnectionContext#getAttribute(String name)
> This would be made available in the HttpContext of a request (like the connection is today):
> HttpConnectionContext connectionContext = (HttpConnectionContext) httpContext.getAttribute(ExecutionContext.HTTP_CONNECTION_CONTEXT);
> This would make a few things much cleaner to implement than they are today: The most obvious being my current use case of wanting connection isolated cookies.
> Currently to achieve this goal we need to provide custom client connection + connection operator + connection manager implementations. Then there is no clean way to currently obtain the actual connection instance created by a custom operator in the HttpContext: As it's wrapped by the connection pool and #getWrappedConnection is protected - so we need to resort to reflection in interceptors.
> Providing a clean mechanism for attaching user defined attributes to a connection instance as described above would make such implementations far far simpler.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] Commented: (HTTPCLIENT-915) Provide a clean mechanism to attatch user define attributes to connections

Posted by "Ortwin Glück (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCLIENT-915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12835704#action_12835704 ] 

Ortwin Glück commented on HTTPCLIENT-915:
-----------------------------------------

I see your point. Anyway I think it's a bit questionable design. This basically introduces global variables, very well comparable with thread-local variables. We all know where that leads if you start passing all sorts of information around that way. Better keep local Maps with the Connection as the (weak ref) key. You can better controll access to those maps individually.

> Provide a clean mechanism to attatch user define attributes to connections
> --------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-915
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-915
>             Project: HttpComponents HttpClient
>          Issue Type: New Feature
>          Components: HttpConn
>    Affects Versions: 4.0.1
>            Reporter: dave irving
>            Priority: Minor
>             Fix For: 4.1 Alpha2
>
>
> It would be nice to have a way to attach user defined attributes to a connection.
> Ideally it'd be nice if such support could be added to HttpClientConnection, but understandably this may not be possible due to back-compatibility issues.
> So, we could have something like HttpConnectionContext perhaps (or similar) with:
> HttpConnectionContext#setAttribute(String name, Object value)
> Object HttpConnectionContext#getAttribute(String name)
> This would be made available in the HttpContext of a request (like the connection is today):
> HttpConnectionContext connectionContext = (HttpConnectionContext) httpContext.getAttribute(ExecutionContext.HTTP_CONNECTION_CONTEXT);
> This would make a few things much cleaner to implement than they are today: The most obvious being my current use case of wanting connection isolated cookies.
> Currently to achieve this goal we need to provide custom client connection + connection operator + connection manager implementations. Then there is no clean way to currently obtain the actual connection instance created by a custom operator in the HttpContext: As it's wrapped by the connection pool and #getWrappedConnection is protected - so we need to resort to reflection in interceptors.
> Providing a clean mechanism for attaching user defined attributes to a connection instance as described above would make such implementations far far simpler.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] Commented: (HTTPCLIENT-915) Provide a clean mechanism to attatch user define attributes to connections

Posted by "Ortwin Glück (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCLIENT-915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12835667#action_12835667 ] 

Ortwin Glück commented on HTTPCLIENT-915:
-----------------------------------------

I think a simple Object is enough. If you need name/value pairs you can store a Map there. Access to the object should be synchronized to or use a volatile field.

> Provide a clean mechanism to attatch user define attributes to connections
> --------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-915
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-915
>             Project: HttpComponents HttpClient
>          Issue Type: New Feature
>          Components: HttpConn
>    Affects Versions: 4.0.1
>            Reporter: dave irving
>            Priority: Minor
>             Fix For: 4.1 Alpha2
>
>
> It would be nice to have a way to attach user defined attributes to a connection.
> Ideally it'd be nice if such support could be added to HttpClientConnection, but understandably this may not be possible due to back-compatibility issues.
> So, we could have something like HttpConnectionContext perhaps (or similar) with:
> HttpConnectionContext#setAttribute(String name, Object value)
> Object HttpConnectionContext#getAttribute(String name)
> This would be made available in the HttpContext of a request (like the connection is today):
> HttpConnectionContext connectionContext = (HttpConnectionContext) httpContext.getAttribute(ExecutionContext.HTTP_CONNECTION_CONTEXT);
> This would make a few things much cleaner to implement than they are today: The most obvious being my current use case of wanting connection isolated cookies.
> Currently to achieve this goal we need to provide custom client connection + connection operator + connection manager implementations. Then there is no clean way to currently obtain the actual connection instance created by a custom operator in the HttpContext: As it's wrapped by the connection pool and #getWrappedConnection is protected - so we need to resort to reflection in interceptors.
> Providing a clean mechanism for attaching user defined attributes to a connection instance as described above would make such implementations far far simpler.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] Updated: (HTTPCLIENT-915) Provide a clean mechanism to attatch user define attributes to connections

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCLIENT-915?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oleg Kalnichevski updated HTTPCLIENT-915:
-----------------------------------------

    Fix Version/s: 4.1 Alpha2

> Provide a clean mechanism to attatch user define attributes to connections
> --------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-915
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-915
>             Project: HttpComponents HttpClient
>          Issue Type: New Feature
>          Components: HttpConn
>    Affects Versions: 4.0.1
>            Reporter: dave irving
>            Priority: Minor
>             Fix For: 4.1 Alpha2
>
>
> It would be nice to have a way to attach user defined attributes to a connection.
> Ideally it'd be nice if such support could be added to HttpClientConnection, but understandably this may not be possible due to back-compatibility issues.
> So, we could have something like HttpConnectionContext perhaps (or similar) with:
> HttpConnectionContext#setAttribute(String name, Object value)
> Object HttpConnectionContext#getAttribute(String name)
> This would be made available in the HttpContext of a request (like the connection is today):
> HttpConnectionContext connectionContext = (HttpConnectionContext) httpContext.getAttribute(ExecutionContext.HTTP_CONNECTION_CONTEXT);
> This would make a few things much cleaner to implement than they are today: The most obvious being my current use case of wanting connection isolated cookies.
> Currently to achieve this goal we need to provide custom client connection + connection operator + connection manager implementations. Then there is no clean way to currently obtain the actual connection instance created by a custom operator in the HttpContext: As it's wrapped by the connection pool and #getWrappedConnection is protected - so we need to resort to reflection in interceptors.
> Providing a clean mechanism for attaching user defined attributes to a connection instance as described above would make such implementations far far simpler.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] Commented: (HTTPCLIENT-915) Provide a clean mechanism to attatch user define attributes to connections

Posted by "dave irving (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCLIENT-915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12835706#action_12835706 ] 

dave irving commented on HTTPCLIENT-915:
----------------------------------------

> Better keep local Maps with the Connection as the (weak ref) key. You can 
> better controll access to those maps individually.

Thats quite a PITA just to get connection specific attributes.

> I see your point. Anyway I think it's a bit questionable design. This basically introduces 
> global variables, very well comparable with thread-local variables.

I'd say its a pretty well trodden ground: HttpContext?

> Provide a clean mechanism to attatch user define attributes to connections
> --------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-915
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-915
>             Project: HttpComponents HttpClient
>          Issue Type: New Feature
>          Components: HttpConn
>    Affects Versions: 4.0.1
>            Reporter: dave irving
>            Priority: Minor
>             Fix For: 4.1 Alpha2
>
>
> It would be nice to have a way to attach user defined attributes to a connection.
> Ideally it'd be nice if such support could be added to HttpClientConnection, but understandably this may not be possible due to back-compatibility issues.
> So, we could have something like HttpConnectionContext perhaps (or similar) with:
> HttpConnectionContext#setAttribute(String name, Object value)
> Object HttpConnectionContext#getAttribute(String name)
> This would be made available in the HttpContext of a request (like the connection is today):
> HttpConnectionContext connectionContext = (HttpConnectionContext) httpContext.getAttribute(ExecutionContext.HTTP_CONNECTION_CONTEXT);
> This would make a few things much cleaner to implement than they are today: The most obvious being my current use case of wanting connection isolated cookies.
> Currently to achieve this goal we need to provide custom client connection + connection operator + connection manager implementations. Then there is no clean way to currently obtain the actual connection instance created by a custom operator in the HttpContext: As it's wrapped by the connection pool and #getWrappedConnection is protected - so we need to resort to reflection in interceptors.
> Providing a clean mechanism for attaching user defined attributes to a connection instance as described above would make such implementations far far simpler.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] Commented: (HTTPCLIENT-915) Provide a clean mechanism to attatch user define attributes to connections

Posted by "dave irving (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCLIENT-915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12835715#action_12835715 ] 

dave irving commented on HTTPCLIENT-915:
----------------------------------------

I completely agree with you, Oleg. 

This feature certainly would have scope for misunderstanding / misuse - and I'd guess javadocs should point out what it's there for, and what it's not. 

My actual use case here is Connection specific cookies (Appears to have been needed by other users too).

If there are concerns that providing a connection context interface could possibly lead to confusion (e.g. clients not making the distinction between it and HttpContext, or not realising that 99% of the time they shouldn't be attaching state to connections), I'd be equally happy with any other solution that allows this use case to be met without resorting to the currently required reflection hacks:

Any of:

- Provide a a configuration parameter explicity for this case "CONNECTION_ISOLATED_COOKIES" or somesuch
- If a user implements a custom connection / operator / manager etc, provide them with some way to actually get hold of their custom connection implementation during request execution without requiring the use of reflection

Overall though, I tend to favour the connection attributes approach:

- Obviates the need to write custom connection / operator / manager classes just to provide connection state (which is needed in some scenarios, e.g, this use case)
- Is less dangerous than exposing unwrapped connections during request execution (which could expose circumvention of pooling etc)

> Provide a clean mechanism to attatch user define attributes to connections
> --------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-915
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-915
>             Project: HttpComponents HttpClient
>          Issue Type: New Feature
>          Components: HttpConn
>    Affects Versions: 4.0.1
>            Reporter: dave irving
>            Priority: Minor
>             Fix For: 4.1 Alpha2
>
>
> It would be nice to have a way to attach user defined attributes to a connection.
> Ideally it'd be nice if such support could be added to HttpClientConnection, but understandably this may not be possible due to back-compatibility issues.
> So, we could have something like HttpConnectionContext perhaps (or similar) with:
> HttpConnectionContext#setAttribute(String name, Object value)
> Object HttpConnectionContext#getAttribute(String name)
> This would be made available in the HttpContext of a request (like the connection is today):
> HttpConnectionContext connectionContext = (HttpConnectionContext) httpContext.getAttribute(ExecutionContext.HTTP_CONNECTION_CONTEXT);
> This would make a few things much cleaner to implement than they are today: The most obvious being my current use case of wanting connection isolated cookies.
> Currently to achieve this goal we need to provide custom client connection + connection operator + connection manager implementations. Then there is no clean way to currently obtain the actual connection instance created by a custom operator in the HttpContext: As it's wrapped by the connection pool and #getWrappedConnection is protected - so we need to resort to reflection in interceptors.
> Providing a clean mechanism for attaching user defined attributes to a connection instance as described above would make such implementations far far simpler.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org