--===============0213700755405151323== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable > On Oct. 12, 2011, 10:58 p.m., Andreas Hartmetz wrote: > > kioslave/http/http.cpp, line 3107 > > > > > > I guess the parser just lowercases the key ("keep-alive"), not the = values. Lowercasing the keys is okay because per the spec they are case-ins= ensitive, and it has the advantage that you can look up keys in more or les= s constant time when using a hashtable. > > In many cases the values are case sensitive (usernames, something B= ase64-encoded for example), so the parser better leaves them alone. So you = need to normalize the case yourself. Small addition: The values are key-value pairs again here, but that isn't u= niversally so in HTTP headers. The header parser simply doesn't know about = such details. - Andreas ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: http://git.reviewboard.kde.org/r/102822/#review7283 ----------------------------------------------------------- On Oct. 10, 2011, 10:35 p.m., Andrea Iacovitti wrote: > = > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > http://git.reviewboard.kde.org/r/102822/ > ----------------------------------------------------------- > = > (Updated Oct. 10, 2011, 10:35 p.m.) > = > = > Review request for kdelibs, Andreas Hartmetz and Dawit Alemayehu. > = > = > Description > ------- > = > Keep-alive header can specify multiple, comma-separated, value pairs. > For example what apache web server normally sends is something like that: > = > "Keep-Alive: timeout=3D5, max=3D99" > = > Actually kio_http fails to extract timeout value because it assumes > keep-alive header can contain only a single value pair. > In the case of example above what it end up to do is > m_request.keepAliveTimeout =3D QString("5, max=3D99").toInt(), that retur= ns 0 (wrong!). > = > = > Diffs > ----- > = > kioslave/http/http.cpp 2862707 = > kioslave/http/parsinghelpers.cpp fc75d68 = > = > Diff: http://git.reviewboard.kde.org/r/102822/diff/diff > = > = > Testing > ------- > = > -Patched code compiles > -Hacked a web server and made tests against following keep-alive header v= ariants: > "Keep-Alive: timeout=3D5, max=3D99" > "Keep-Alive: Timeout=3D5, max=3D99" (uppercase 'T') > "Keep-Alive: Timeout=3D5 , max=3D99" (extra space before comma) > = > = > Thanks, > = > Andrea Iacovitti > = > --===============0213700755405151323== Content-Type: text/html; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable
This is an automatically generated e-mail. To reply, visit: http://git.revie= wboard.kde.org/r/102822/

On October 12th, 2011, 10:58 p.m., Andreas = Hartmetz wrote:

= = =
kioslave/http/http.cpp (Diff revision 1)
endParsing:
3107
            if (tIt.<=
span class=3D"n">next().s=
tartsWith("timeout=
=3D")) { // krazy:exclude=3Dstrings
3107
            QByteArray ka =3D tIt.next().trimmed().toLower();
I guess t=
he parser just lowercases the key ("keep-alive"), not the values.=
 Lowercasing the keys is okay because per the spec they are case-insensitiv=
e, and it has the advantage that you can look up keys in more or less const=
ant time when using a hashtable.
In many cases the values are case sensitive (usernames, something Base64-en=
coded for example), so the parser better leaves them alone. So you need to =
normalize the case yourself.
Small addition: The values are key-value pairs again here, but that =
isn't universally so in HTTP headers. The header parser simply doesn=
9;t know about such details.

- Andreas


On October 10th, 2011, 10:35 p.m., Andrea Iacovitti wrote:

Review request for kdelibs, Andreas Hartmetz and Dawit Alemayehu.
By Andrea Iacovitti.

Updated Oct. 10, 2011, 10:35 p.m.

Descripti= on

Keep-alive header can specify multiple, comma-separated, val=
ue pairs.
For example what apache web server normally sends is something like that:

"Keep-Alive: timeout=3D5, max=3D99"

Actually kio_http fails to extract timeout value because it assumes
keep-alive header can contain only a single value pair.
In the case of example above what it end up to do is
m_request.keepAliveTimeout =3D QString("5, max=3D99").toInt(), th=
at returns 0 (wrong!).

Testing <= /h1>
-Patched code compiles
-Hacked a web server and made tests against following keep-alive header var=
iants:
 "Keep-Alive: timeout=3D5, max=3D99"
 "Keep-Alive: Timeout=3D5, max=3D99"     (uppercase 'T')
 "Keep-Alive: Timeout=3D5 , max=3D99"    (extra space before comm=
a)

Diffs=

  • kioslave/http/http.cpp (2862707)
  • kioslave/http/parsinghelpers.cpp (fc75d68)=

View Diff

--===============0213700755405151323==--