Re: Return a 200 0K status and send the content of the request later

Mithun Bhattacharya <[email protected]> Tue, 13 May 2025 14:57:15 -0500
Newsgroups gmane.comp.apache.mod-perl
Message-ID <CAHTPV9+nUW1Mz6isZswMJ8d2MiGFd2agFazxSnduefQ4=g8P1A@mail.gmail.com>
--0000000000007feb7f063509d743
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Http return codes are relevant only for request with fast response time. It
helps the requestor get a quick status 200 is all good, 3xx something
temporary, 4xx client has made some mistakes and 5xx server faulted.

Unfortunately this design doesn't map well to requests which take
significant execution time.

The easiest way to solve this is respond with 200 OK and then the body
tells you whether it succeeded or not. This is not something which is
defined in any place nor is it considered bad.

Hence if you are writing a mod_perl handler for such an endpoint you return
success immediately and then start processing the request. In most cases
this is simply a matter of doing $r->print on the headers followed by print
of two new lines.

On Tue, May 13, 2025, 2:33=E2=80=AFPM Vincent Veyron <[email protected]> =
wrote:

> On Wed, 23 Apr 2025 15:06:44 -0500
> Mithun Bhattacharya <[email protected]> wrote:
>
> Hi Mithun,
>
> In a recent thread, you wrote :
>
> >
> > mod_perl code is where you are sending the http return status to make
> sure
> > the client doesn't timeout waiting for the server to respond.
> >
>
> Could you explain how this is done, I thought one had to send the content
> with the headers?
>
> I have a function in my web application which allows users to download th=
e
> entirety of their data in the form of a postgresql dump, wrapped in a zip
> file. The files are getting bigger, and take more time to generate and
> download, so I'm going to hit the timeout one day.
>
>
> --
>                                         Bien =C3=A0 vous, Vincent Veyron
>
> https://marica.fr/
> Logiciel de gestion des sinistres assurances, des dossiers contentieux et
> des contrats pour le service juridique
>

--0000000000007feb7f063509d743
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<p dir=3D"ltr">Http return codes are relevant only for request with fast re=
sponse time. It helps the requestor get a quick status 200 is all good, 3xx=
 something temporary, 4xx client has made some mistakes and 5xx server faul=
ted.</p>
<p dir=3D"ltr">Unfortunately this design doesn&#39;t map well to requests w=
hich take significant execution time.</p>
<p dir=3D"ltr">The easiest way to solve this is respond with 200 OK and the=
n the body tells you whether it succeeded or not. This is not something whi=
ch is defined in any place nor is it considered bad.</p>
<p dir=3D"ltr">Hence if you are writing a mod_perl handler for such an endp=
oint you return success immediately and then start processing the request. =
In most cases this is simply a matter of doing $r-&gt;print on the headers =
followed by print of two new lines.</p>
<br><div class=3D"gmail_quote gmail_quote_container"><div dir=3D"ltr" class=
=3D"gmail_attr">On Tue, May 13, 2025, 2:33=E2=80=AFPM Vincent Veyron &lt;<a=
 href=3D"mailto:[email protected]">[email protected]</a>&gt; wrote:<br>=
</div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-l=
eft:1px #ccc solid;padding-left:1ex">On Wed, 23 Apr 2025 15:06:44 -0500<br>
Mithun Bhattacharya &lt;<a href=3D"mailto:[email protected]" target=3D"_blan=
k" rel=3D"noreferrer">[email protected]</a>&gt; wrote:<br>
<br>
Hi Mithun,<br>
<br>
In a recent thread, you wrote :<br>
<br>
&gt; <br>
&gt; mod_perl code is where you are sending the http return status to make =
sure<br>
&gt; the client doesn&#39;t timeout waiting for the server to respond.<br>
&gt; <br>
<br>
Could you explain how this is done, I thought one had to send the content w=
ith the headers?<br>
<br>
I have a function in my web application which allows users to download the =
entirety of their data in the form of a postgresql dump, wrapped in a zip f=
ile. The files are getting bigger, and take more time to generate and downl=
oad, so I&#39;m going to hit the timeout one day. <br>
<br>
<br>
-- <br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Bien =C3=
=A0 vous, Vincent Veyron<br>
<br>
<a href=3D"https://marica.fr/" rel=3D"noreferrer noreferrer" target=3D"_bla=
nk">https://marica.fr/</a><br>
Logiciel de gestion des sinistres assurances, des dossiers contentieux et d=
es contrats pour le service juridique<br>
</blockquote></div>

--0000000000007feb7f063509d743--