You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Bill Speirs <bi...@gmail.com> on 2011/08/25 21:21:34 UTC

ContentType Constants

I just pulled in the fluent-hc code and noticed there was a
ContentType class:
fluent-hc/src/main/java/org/apache/http/client/fluent/header/ContentType.java.
This class defines a handful of constants: HTML, JPEG, PNG, GIF, TEXT,
XML, and JSON.

There is already a ContentType class in the core code:
httpcore/src/main/java/org/apache/http/entity/ContentType.java.
However, this class does not define any constants.

Finally, there is a MediaType class in javax.ws.rs.core. It defines a
number of constants as well.

All of this, I believe, causes a bit of confusion when I need to
specify a Content Type. Which class should I be using?

I see 2 options:

1) Scrap the ContentType class in fluent-hc, keep the one in httpcore,
and make a note in the JavaDocs of httpcore that if you want constants
please use javax.ws.rs.core.MediaType.
2) Scrap the ContentType class in fluent-hc, keep the one in httpcore,
pull all of the types in MediaType into the ContentType class in
httpcore

Thoughts?

Bill-

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


Re: ContentType Constants

Posted by Bill Speirs <bi...@gmail.com>.
For the purposes of cross-referencing:
https://issues.apache.org/jira/browse/HTTPCORE-271

Bill-

On Fri, Aug 26, 2011 at 9:39 AM, Oleg Kalnichevski <ol...@apache.org> wrote:
> On Thu, 2011-08-25 at 15:21 -0400, Bill Speirs wrote:
>> I just pulled in the fluent-hc code and noticed there was a
>> ContentType class:
>> fluent-hc/src/main/java/org/apache/http/client/fluent/header/ContentType.java.
>> This class defines a handful of constants: HTML, JPEG, PNG, GIF, TEXT,
>> XML, and JSON.
>>
>> There is already a ContentType class in the core code:
>> httpcore/src/main/java/org/apache/http/entity/ContentType.java.
>> However, this class does not define any constants.
>>
>> Finally, there is a MediaType class in javax.ws.rs.core. It defines a
>> number of constants as well.
>>
>> All of this, I believe, causes a bit of confusion when I need to
>> specify a Content Type. Which class should I be using?
>>
>> I see 2 options:
>>
>> 1) Scrap the ContentType class in fluent-hc, keep the one in httpcore,
>> and make a note in the JavaDocs of httpcore that if you want constants
>> please use javax.ws.rs.core.MediaType.
>> 2) Scrap the ContentType class in fluent-hc, keep the one in httpcore,
>> pull all of the types in MediaType into the ContentType class injavax.ws.rs.core
>> httpcore
>>
>> Thoughts?
>>
>> Bill-
>>
>
> The fluent facade API is still in a very early state of development.
> Nothing is final. I think it does make sense to re-use ContentType code
> from HttpCore. I am not sure we should use javax.ws.rs.core, though, as
> long as we want to keep JSE 1.5 as a minimal runtime level requirement.
>
> Do feel free to put changes you are proposing into a patch.
>
> Cheers
>
> Oleg
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> For additional commands, e-mail: dev-help@hc.apache.org
>
>

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


Re: ContentType Constants

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Thu, 2011-08-25 at 15:21 -0400, Bill Speirs wrote:
> I just pulled in the fluent-hc code and noticed there was a
> ContentType class:
> fluent-hc/src/main/java/org/apache/http/client/fluent/header/ContentType.java.
> This class defines a handful of constants: HTML, JPEG, PNG, GIF, TEXT,
> XML, and JSON.
> 
> There is already a ContentType class in the core code:
> httpcore/src/main/java/org/apache/http/entity/ContentType.java.
> However, this class does not define any constants.
> 
> Finally, there is a MediaType class in javax.ws.rs.core. It defines a
> number of constants as well.
> 
> All of this, I believe, causes a bit of confusion when I need to
> specify a Content Type. Which class should I be using?
> 
> I see 2 options:
> 
> 1) Scrap the ContentType class in fluent-hc, keep the one in httpcore,
> and make a note in the JavaDocs of httpcore that if you want constants
> please use javax.ws.rs.core.MediaType.
> 2) Scrap the ContentType class in fluent-hc, keep the one in httpcore,
> pull all of the types in MediaType into the ContentType class injavax.ws.rs.core
> httpcore
> 
> Thoughts?
> 
> Bill-
> 

The fluent facade API is still in a very early state of development.
Nothing is final. I think it does make sense to re-use ContentType code
from HttpCore. I am not sure we should use javax.ws.rs.core, though, as
long as we want to keep JSE 1.5 as a minimal runtime level requirement.

Do feel free to put changes you are proposing into a patch.

Cheers

Oleg



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