Issue Details (XML | Word | Printable)

Key: HTTPCORE-13
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Roland Weber
Reporter: Roland Weber
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
HttpComponents HttpCore

AbstractHttpProcessor is not really abstract

Created: 25/Sep/06 01:16 PM   Updated: 02/Oct/06 06:59 AM
Return to search
Component/s: HttpCore
Affects Version/s: 4.0-alpha3
Fix Version/s: 4.0-alpha3

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works 2k6-09-25-core-proc-1.txt 2006-09-25 01:22 PM Roland Weber 22 kB

Resolution Date: 02/Oct/06 06:59 AM


 Description  « Hide
AbstractHttpProcessor is declared abstract though it does not have any abstract method. This artificially restricts use of the base class functionality to subclassing and prohibits use by reference. That is one of the reasons why HttpAsync has an ugly AsyncHttpProcessor class.

Patch follows.


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Roland Weber added a comment - 25/Sep/06 01:22 PM
Take 1. Idea:

- define an interface for processing requests and responses
- turn AbstractHttpProcessor into DefaultHttpProcessor, make processing methods public
- move default implementation to an implementation package
- HttpRequestExecutor and HttpService can no longer derive from DefaultHttpProcessor,
  since it is in an implementation package

Observation: HttpService is in an API package but imports and instantiates two implementation classes.
Maybe we should reconsider the whole protocol package with respect to API vs. implementation.

Please let me know what you think.

cheers,
  Roland


Oleg Kalnichevski added a comment - 25/Sep/06 02:01 PM
> - define an interface for processing requests and responses
> - turn AbstractHttpProcessor into DefaultHttpProcessor, make processing methods public
> - move default implementation to an implementation package
> - HttpRequestExecutor and HttpService can no longer derive from DefaultHttpProcessor,
> since it is in an implementation package

Makes sense. Wouldn 't HttpInterceptorChain be a better name for this interface, though?

> Observation: HttpService is in an API package but imports and instantiates two implementation classes.
> Maybe we should reconsider the whole protocol package with respect to API vs. implementation.

You are right. This needs to be fixed

Oleg

Roland Weber added a comment - 25/Sep/06 04:26 PM
Hi Oleg,

> Wouldn 't HttpInterceptorChain be a better name for this interface, though?

The interface in the patch makes no reference to interceptors except in the JavaDoc.
If we include methods to add/remove interceptors to the interface, I agree.
Right now, those methods are only in the implementation class.
I think we'll have more of them in the future (like index-based ones),
and I am reluctant to add the full selection to the interface.
Read-only is enough for both request executor and service.

cheers,
  Roland

Oleg Kalnichevski added a comment - 25/Sep/06 05:37 PM
Fair enough. Please go ahead and commit the patch

Oleg

Roland Weber added a comment - 25/Sep/06 05:56 PM
take 1 committed with minor modifications to JavaDocs

I also fixed HttpAsync so that it compiles again. The async fix is minimal and ugly. Things will have to be straightened out later by eliminating AsyncHttpProcessor altogether. The remaining functionality used from HttpRequestExecutor can be provided in AbstractHttpDispatcher instead.

cheers,
  Roland

Oleg Kalnichevski added a comment - 25/Sep/06 08:12 PM
Roland,

I still somehow can't help feeling that HttpProcessor is not a very appropriate name for this interface. Would the following changes be okay with you?

Rename: HttpProcessor -> HttpProtocolHandler

Rename: DefaultHttpProcessor -> o.a.http.protocol.BasicHttpProtocolHandler

Add: class o.a.http.protocol.HttpClientProtocolHandler extends o.a.http.protocol.BasicHttpProtocolHandler {

  public HttpClientProtocolHandler() {
    super();
    addInterceptor(new RequestContent());
    addInterceptor(new RequestTargetHost());
    addInterceptor(new RequestConnControl());
    addInterceptor(new RequestUserAgent());
    addInterceptor(new RequestExpectContinue());
  }

}

Add: class o.a.http.protocol.HttpServerProtocolHandler extends o.a.http.protocol.BasicHttpProtocolHandler {

  public HttpClientProtocolHandler() {
    super();
    addInterceptor(new ResponseDate());
    addInterceptor(new ResponseServer());
    addInterceptor(new ResponseContent());
    addInterceptor(new ResponseConnControl());
  }

}

Roland Weber added a comment - 26/Sep/06 06:47 PM
Hi Oleg,

I kind of feel that HttpProtocolHandler does not give the slightest indication what the class is supposed to do.
I liked the HttpInterceptorChain suggestion better. When I worked on the patch I also considered HttpMessageProcessor.
HTTP protocol handling is much more than just setting up or interpreting a few headers. Of course,
processing is also a very generic term. Some clicks on WordNet (http://wordnet.princeton.edu/perl/webwn)
lead me to "shape" or "mould" as alternatives to indicate that the purpose is to bring a message into a
particular form suitable for the following step. HttpMessageShaper? HttpMessageSculptor? ;-)
HttpMessageFilter is probably misleading.

cheers,
  Roland


Oleg Kalnichevski added a comment - 26/Sep/06 07:04 PM
All right. As always we agree to disagree. Can we at the very least get rid of the o.a.http.impl.protocol package? In my opinion it makes sense to keep the BasicHttpProcessor class as a part of the public API.

Oleg

Roland Weber added a comment - 26/Sep/06 07:22 PM
Hi Oleg,

no problem. You can also change HttpRequestExecutor and HttpService back to subclassing, if you prefer that.
I only changed them to use a reference because I moved the implementation to an impl package.

cheers,
  Roland

Oleg Kalnichevski added a comment - 26/Sep/06 07:41 PM
> no problem.

Done.

> You can also change HttpRequestExecutor and HttpService back to subclassing, if you prefer that.

I actually like it the way it is now. We now have an option to pass a customized (thread-safe, for instance) version of HttpProcessor to HttpRequestExecutor and HttpService. This can certainly come handy.

Oleg

Roland Weber added a comment - 27/Sep/06 05:13 PM
Hi Oleg,

here are a few names I'd feel comfortable with, in alphabetical order:

HttpHeaderHandler
HttpHeaderProcessor
HttpInterceptHandler
HttpInterceptionHandler
HttpPrePostProcessor

cheers,
  Roland

Oleg Kalnichevski added a comment - 27/Sep/06 06:09 PM
> HttpHeaderHandler
> HttpHeaderProcessor

Interceptors can also re-write entity conent, so these names would be somewhat misleading

> HttpInterceptHandler
> HttpInterceptionHandler
> HttpPrePostProcessor

HttpInterceptorChain would be my favourite. But what if we just dropped pre- and post- from method names and kept the interface name?

Oleg

Roland Weber added a comment - 28/Sep/06 05:26 PM
Hi Oleg,

> HttpInterceptorChain would be my favourite. But what if we just dropped
> pre- and post- from method names and kept the interface name?

I'm fine with that, too. We could also go one step further and align the method names
with those in Http{Request|Response}Interceptor. Then we'd have hierarchical sets
of interceptors :-)

cheers,
  Roland

Oleg Kalnichevski added a comment - 28/Sep/06 07:07 PM
> I'm fine with that, too. We could also go one step further and align the method names
> with those in Http{Request|Response}Interceptor. Then we'd have hierarchical sets
> of interceptors :-)

Sounds like a plan.

Oleg

Oleg Kalnichevski added a comment - 28/Sep/06 07:23 PM
> HttpService is in an API package but imports and instantiates two implementation classes.

Fixed.

Oleg

Oleg Kalnichevski added a comment - 01/Oct/06 06:35 PM
Is there still anything that needs work? Can this issue be closed?

Oleg

Roland Weber added a comment - 02/Oct/06 06:59 AM
Done with it all.