[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kfm-devel
Subject:    Re: Using KIO to retrive HTTP Headers [GSoC student help request]
From:       Dawit A <adawit () kde ! org>
Date:       2012-07-13 6:41:06
Message-ID: CALa28R4-NcMVxbsnOk5+7NBL+hiAtcPTqJnVFGurRRAcQtnp7w () mail ! gmail ! com
[Download RAW message or body]

On Thu, Jul 12, 2012 at 11:16 PM, Aish Raj Dahal <dahalaishraj@gmail.com>wrote:

> On Thu, Jul 12, 2012 at 9:09 PM, David Faure <faure@kde.org> wrote:
> > On Wednesday 11 July 2012 11:53:51 Aish Raj Dahal wrote:
> >> 1) Case One : When mimetype signal emitted by KIO::TransferJob is used
> >>
> >> In order to clarify more, let me take an example file
> >>
> https://github.com/ardahal/kio-learner/blob/ard-dev/metalinkHttp/metalinkHtt
> >> p.cpp . The given file uses the mimetype signal (at line 44) to get the
> >> headers as soon as the mimetype is emitted. The catch is, since we do
> >> no want the redirected HTTP headers but instead want the original HTTP
> >> headers, setRedirectionHandlingEnabled has been set to false. This
> >> program when run, does not emit the mimetype signal as all, and as a
> >> result the qDebugs at line 51 and 52 are never executed . This
> >> behavior is seen not only for URLs which redirect (like
> >> http://www.example.com ) but also for URLs which have no redirection
> >> (like http://www.google.com.np) .
> >
> > This is the part that makes no sense to me ;-)
> >
> > redirectionHandlingEnabled is a KIO::SimpleJob setting, the slave has no
> idea
> > about that setting. If there's no redirection, then none of the code in
> > simplejob that checks for redirectionHandlingEnabled actually runs.
> > So it can't possibly make any difference for a URL without redirection.
> >
> > I think your testcase is a bit wrong: http://www.google.com.npredirects. I
> > can see it in the konqueror debug output:
> >
> >  KonqRun::slotRedirection: KUrl("http://www.google.com.np") ->
> > KUrl("http://www.google.com.np/")
> >
> > So if you want to test a URL that doesn't redirect, add the trailing
> slash
> > upfront.
> >
> > If you can confirm this, then we'll be down to: no http headers emitted
> when a
> > redirection happens, which would be a kio_http issue. Dawit?
> >
>
> Thanks a lot for the heads up about the test case :-)
>
> It does indeed run well as expected with
> KUrl("http://www.google.com.np/") as the test URL. However for those
> URLs that do have redirection, no headers were emitted.
>
> Once again, thanks a lot.
>

I will try and clarify some things as much as I can:

#1. Without some changes in kio_http, you will never see redirection
headers received from HTTP server. This can probably be addressed by
delaying the redirection request until after the HTTP headers have been
set. However, the last time I attempted to fix this, it caused a
regression. See bug#150904.

#2. When a redirection is requested, kio_http will never emit mimeType
signal because it is not yet known. This should be very obvious because a
redirection request is the server telling us the actual location of the
content we just requested. As such connecting to KIO's mimeType signal for
such circumstances is of no use.

#3. If you do setRedirectionHandlingEnabled(false) in order to handle
redirections yourself, instead of KIO, then you have to connect to KIO's
redirect signal and retrieve the redirect URL. IOW, you have to do the same
thing you are doing in your "output" function from the slot connected to
the redirection signals.

However, I suspect what you want to do is get any and all headers including
those that have to do with redirection requests. If so, then we have to
find a way for kio_http to set the HTTP headers before sending the
redirection request without causing a regression.

[Attachment #3 (text/html)]

<br><br><div class="gmail_quote">On Thu, Jul 12, 2012 at 11:16 PM, Aish Raj Dahal \
<span dir="ltr">&lt;<a href="mailto:dahalaishraj@gmail.com" \
target="_blank">dahalaishraj@gmail.com</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">

<div class="HOEnZb"><div class="h5">On Thu, Jul 12, 2012 at 9:09 PM, David Faure \
&lt;<a href="mailto:faure@kde.org">faure@kde.org</a>&gt; wrote:<br> &gt; On Wednesday \
11 July 2012 11:53:51 Aish Raj Dahal wrote:<br> &gt;&gt; 1) Case One : When mimetype \
signal emitted by KIO::TransferJob is used<br> &gt;&gt;<br>
&gt;&gt; In order to clarify more, let me take an example file<br>
&gt;&gt; <a href="https://github.com/ardahal/kio-learner/blob/ard-dev/metalinkHttp/metalinkHtt" \
target="_blank">https://github.com/ardahal/kio-learner/blob/ard-dev/metalinkHttp/metalinkHtt</a><br>
 &gt;&gt; p.cpp . The given file uses the mimetype signal (at line 44) to get the<br>
&gt;&gt; headers as soon as the mimetype is emitted. The catch is, since we do<br>
&gt;&gt; no want the redirected HTTP headers but instead want the original HTTP<br>
&gt;&gt; headers, setRedirectionHandlingEnabled has been set to false. This<br>
&gt;&gt; program when run, does not emit the mimetype signal as all, and as a<br>
&gt;&gt; result the qDebugs at line 51 and 52 are never executed . This<br>
&gt;&gt; behavior is seen not only for URLs which redirect (like<br>
&gt;&gt; <a href="http://www.example.com" target="_blank">http://www.example.com</a> \
) but also for URLs which have no redirection<br> &gt;&gt; (like <a \
href="http://www.google.com.np" target="_blank">http://www.google.com.np</a>) .<br> \
&gt;<br> &gt; This is the part that makes no sense to me ;-)<br>
&gt;<br>
&gt; redirectionHandlingEnabled is a KIO::SimpleJob setting, the slave has no \
idea<br> &gt; about that setting. If there&#39;s no redirection, then none of the \
code in<br> &gt; simplejob that checks for redirectionHandlingEnabled actually \
runs.<br> &gt; So it can&#39;t possibly make any difference for a URL without \
redirection.<br> &gt;<br>
&gt; I think your testcase is a bit wrong: <a href="http://www.google.com.np" \
target="_blank">http://www.google.com.np</a> redirects. I<br> &gt; can see it in the \
konqueror debug output:<br> &gt;<br>
&gt;   KonqRun::slotRedirection: KUrl(&quot;<a href="http://www.google.com.np" \
target="_blank">http://www.google.com.np</a>&quot;) -&gt;<br> &gt; KUrl(&quot;<a \
href="http://www.google.com.np/" \
target="_blank">http://www.google.com.np/</a>&quot;)<br> &gt;<br>
&gt; So if you want to test a URL that doesn&#39;t redirect, add the trailing \
slash<br> &gt; upfront.<br>
&gt;<br>
&gt; If you can confirm this, then we&#39;ll be down to: no http headers emitted when \
a<br> &gt; redirection happens, which would be a kio_http issue. Dawit?<br>
&gt;<br>
<br>
</div></div>Thanks a lot for the heads up about the test case :-)<br>
<br>
It does indeed run well as expected with<br>
KUrl(&quot;<a href="http://www.google.com.np/" \
target="_blank">http://www.google.com.np/</a>&quot;) as the test URL. However for \
those<br> URLs that do have redirection, no headers were emitted.<br>
<br>
Once again, thanks a lot.<br></blockquote><div><br></div><div>I will try and clarify \
some things as much as I can:</div><div><br></div><div>#1. Without some changes in \
kio_http, you will never see redirection headers received from HTTP server. This can \
probably be addressed by delaying the redirection request until after the HTTP \
headers have been set. However, the last time I attempted to fix this, it caused a \
regression. See bug#150904.</div>

<div><br></div><div>#2. When a redirection is requested, kio_http will never emit \
mimeType signal because it is not yet known. This should be very obvious because a \
redirection request is the server telling us the actual location of the content we \
just requested. As such connecting to KIO&#39;s mimeType signal for such \
circumstances is of no use.</div>

<div><br></div><div>#3.  If you do  setRedirectionHandlingEnabled(false) in order to \
handle redirections yourself, instead of KIO, then you have to connect to KIO&#39;s \
redirect signal and retrieve the redirect URL. IOW, you have to do the same thing you \
are doing in your &quot;output&quot; function from the slot connected to the \
redirection signals.</div>

<div><br></div><div>However, I suspect what you want to do is get any and all headers \
including those that have to do with redirection requests. If so, then we have to \
find a way for kio_http to set the HTTP headers before sending the redirection \
request  without causing a regression.</div>

</div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic