-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Behrang,

On 12/13/19 00:18, Behrang Saeedzadeh wrote:
> Unless an email, including its signature, is in violation of the
> mailing list policies, no one is in a position to ask participants
> to format their emails in a given way or not to include their email
> signatures. I suggest reading
> https://www.apache.org/foundation/policies/conduct.html and 
> https://apache.org/dev/contrib-email-tips.html for those that are
> not familiar with these policies.

In that case, I'll direct you to
http://tomcat.apache.org/lists.html#tomcat-users which is the policy
for THIS mailing list where you have violated a few items:

1. please state your exact Tomcat version
6. please write your text below the quoted one

It would be very easy for us to change our mailing list policy to
prohibit advertisements (and, frankly, I'm surprised it's not in there
already), but it's much easier to ask politely. The development of
rigid policies are only necessary when bad actors refuse to take
gentle hints.

- -chris
> On Fri, Dec 13, 2019 at 2:08 AM Christopher Schultz < 
> ch...@christopherschultz.net> wrote:
> 
> Behrang,
> 
> On 12/12/19 03:56, Behrang Saeedzadeh wrote:
>>>> Chris,
>>>> 
>>>> 1) Does it make sense to call ServletRequest#getInputStream
>>>> after ServletRequest#getReader? No, and consequently it will
>>>> throw IllegalStateException. 2) Does it make sense to call 
>>>> ServletRequest#getInputStream after ServletRequest#getPart/s?
>>>> No, but it returns an empty stream instead of throwing 
>>>> IllegalStateException.
>>>> 
>>>> These behaviours are not consistent.
> 
> Perhaps, but they do not violate the specification.
> 
> Tomcat must call getInputStream to parse the various 
> multipart/form-data parts. If you call getInputStream, too, there
> will be no error.
> 
> I suspect if you call getReader, you'll find you'll get an 
> IllegalStateException.
> 
>>>> Best regards,
>>>> 
>>>> { "blog" : "https://blog.behrang.org";, "twitter": 
>>>> "https://twitter.com/behrangsa";, "github": 
>>>> "https://github.com/behrangsa/";, "stackoverflow": 
>>>> "https://stackoverflow.com/users/309683?tab=profile"}
> 
> 
> Please stop advertising yourself on a public mailing list.
> 
> -chris
> 
>>>> On Thu, Dec 12, 2019 at 4:31 AM Christopher Schultz < 
>>>> ch...@christopherschultz.net> wrote:
>>>> 
>>>> André,
>>>> 
>>>> On 12/10/19 16:47, André Warnier (tomcat/perl) wrote:
>>>>>>> On 10.12.2019 15:31, Christopher Schultz wrote:
>>>>>>>> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256
>>>>>>>> 
>>>>>>>> Behrang,
>>>>>>>> 
>>>>>>>> On 12/8/19 05:18, Behrang Saeedzadeh wrote:
>>>>>>>>> If I call
>>>>>>>>> javax.servlet.ServletRequest#getInputStream after
>>>>>>>>> having called 
>>>>>>>>> javax.servlet.http.HttpServletRequest#getPart,
>>>>>>>>> even without performing any operations on the given
>>>>>>>>> part, I am getting an empty stream (0-bytes).
>>>>>>>>> 
>>>>>>>>> Is this in compliance with the spec?
>>>>>>>> 
>>>>>>>> What does the servlet spec say about that situation?
>>>>>>>> 
>>>>>>> 
>>>>>>> A bit in defense of the OP, I have to say that the
>>>>>>> Servlet Spec (4.0 final) does not seem extremely clear
>>>>>>> on that subject.
>>>> 
>>>> While I appreciate your research activities, I was hoping the
>>>> OP would actually read the spec to get some clarification.
>>>> 
>>>>>>> In section "3.1.1 When Parameters Are Available", it
>>>>>>> /does/ say this :
>>>>>>> 
>>>>>>> "If the conditions are met, post form data will no
>>>>>>> longer be available for reading directly from the
>>>>>>> request object’s input stream."
>>>>>>> 
>>>>>>> But among those conditions that have to be met (just
>>>>>>> above that quote) is "4. The servlet has made an
>>>>>>> initial call of any of the "getParameter family" of
>>>>>>> methods on the request object."
>>>>>>> 
>>>>>>> (So there, it talks about "the getParameter family",
>>>>>>> not the "getPart" ones).
>>>>>>> 
>>>>>>> It only talks about the "getPart" methods in the next
>>>>>>> section "3.2 File upload", and in that section, all it
>>>>>>> says about the input stream is : "If the servlet
>>>>>>> container does not provide the multi-part/form-data
>>>>>>> processing, the data will be available through the
>>>>>>> HttpServletReuqest.getInputStream."
>>>>>>> 
>>>>>>> So the way I read this, is that there is nothing that 
>>>>>>> explicitly says that the InputStream is no longer
>>>>>>> available if you have called "getPart".
>>>> 
>>>> The only reason the container would process
>>>> multi-part/form-data requests is if you called
>>>> request.getPart*. Therefore, the InputStream is no longer
>>>> available.
>>>> 
>>>>>>> (It is also in fact not very clear about what happens
>>>>>>> to the parameters, when the content-type of the Request
>>>>>>> is "multipart/form-data", which is only mentioned in
>>>>>>> section 3.2.)
>>>> 
>>>> Normal parameters are available via request.getParameter*.
>>>> You can also go through the agony of
>>>> getPart("foo").getInputStream() if you'd like. This is
>>>> documented in section 3.2 "File Upload".
>>>> 
>>>>>>> On the other hand, 
>>>>>>> http://tomcat.apache.org/tomcat-9.0-doc/servletapi/index.html
>>>>>>>
>>>>>>> 
- --> Interface HttpServletRequest says :
>>>>>>> 
>>>>>>> Part getPart(java.lang.String name) throws 
>>>>>>> java.io.IOException, ServletException Gets the named
>>>>>>> Part or null if the Part does not exist. *Triggers
>>>>>>> upload of all Parts*. (emphasis mine)
>>>>>>> 
>>>>>>> which /may/ be taken to mean (and probably does) that
>>>>>>> it consumes the whole InputStream.
>>>> 
>>>> It does. And, necessarily, it must. You can't find out what's
>>>> in the request entity without ... reading the request
>>>> entity.
>>>> 
>>>>>>> But again, this may be lacking some overall clarity.
>>>>>>> 
>>>>>>> In any case, the OP's question is not really
>>>>>>> unwarranted, unless there is some other explanation
>>>>>>> somewhere which I have missed.
>>>> 
>>>> I guess to me this falls under the category of "obvious", but
>>>> then again I know quite a bit about this subject.
>>>> 
>>>> -chris
>>>>> 
>>>>> ------------------------------------------------------------------
- ---
>>>>>
>>>>>
>
>>>>> 
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
>>>>> For additional commands, e-mail:
>>>>> users-h...@tomcat.apache.org
>>>>> 
>>>>> 
>>>> 
>> 
>> ---------------------------------------------------------------------
>>
>> 
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
>> For additional commands, e-mail: users-h...@tomcat.apache.org
>> 
>> 
> 
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl3z/5IACgkQHPApP6U8
pFj7Lw/+L8cm3pfmLVcVLbxNFm4iUTrrfNzlrmrH9ch19ICTyJSf+PQUfI/F2qmR
8MvQL6kf+0MTX85oN+PjDM12Zg1uwHrKaBPiGjIFHIksbhGo183GSCMbQP1hqrQn
Z9HZvdahKrp25v6gLcLp9uBUn+eJvdRqmKTl76Br673YTd2i4HjC2HpwkYQKsi8D
zTPACMo3acRC/iMbri76t6kxfPhC/ILmv7QTBC4holZcyXHgvR48B+LNN7EtbKNN
7nkN5cS/NS1NoKfCfcGfcM9lwaQTylys4IbwPHMwaFGkCTS5YPLHeqj5Fyc9YTTS
9TrmsJTos0+RaIQ0eX3huGF338CTXKVLB/BTFUvdfgQpDleKQbOl9dtKXqEkJiLE
2ahYpeUKODTphTSixS0YjoB4eTBh4QfQbLppOXn/BRhjWsb+/bZxTVc0M5UaBSbS
rEf/QOuX7v5OBeVOoAPFSArmUEbz7EXm+gjQ5vy6smKHuAh6OMXl/TXSfM/6M3SE
xeHZOQiQJH1Jfhokz4RYtSZU4ZSf8DJUaCSf8mLDjzwfhPd67Zod4N82CIQrd/zj
Q/7Ifbisxs/rzwdLGv5vGTLFJpCXSo0jMgcpkFXomCCb7eB0H2FOpLjcGmX2lqkH
01Znz2MhtawkoitCAOzy3Fn/WAzhG/silPaO8VTXRwmNR9QFVTY=
=g4YM
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to