How do I force apache to deliver a file in chunked encoded format
Asked Answered
L

3

6

I am verifying if my application handles file content delivered through chunked-encoding mode. I am not sure what change to make to the httpd.conf file to force chunked encoding through Apache. Is it even possible to do this with Apache server, if not what would be an easier solution? I am using Apache 2.4.2 and HTTP 1.1.

By default, keep-alive is On in Apache and I do not see the data as chunked when testing with wireshark.

EDIT: Added more info:

Lincolnlincolnshire answered 29/4, 2013 at 18:5 Comment(2)
Do you have any more context?Decimate
same problem. I'd like to get Apache to server some files in chunked encoding mode, so that I can verify the client works correctly. Or is there perhaps a server that server variously sized files in chunks?Allhallows
A
1

This resource produces chunked results http://www.httpwatch.com/httpgallery/chunked/ which is very useful for testing clients. You can see this by running

$ curl --raw -i http://www.httpwatch.com/httpgallery/chunked/
HTTP/1.1 200 OK
Cache-Control: private,Public
Transfer-Encoding: chunked
Content-Type: text/html
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Mon, 22 Jul 2013 09:41:04 GMT

7b
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

2d
<html xmlns="http://www.w3.org/1999/xhtml">
....
Allhallows answered 22/7, 2013 at 9:43 Comment(2)
useful for testing, but doesn't answer to the question in any way.Supersedure
URL changed, use curl --raw -v http://www.httpwatch.com/httpgallery/chunked/chunkedimage.aspx | more insteadHusein
H
1

Only way I managed to do this was by enabling the deflate module. Then I configured my client to send "Accept-Encoding: gzip, deflate" header and apache would compress and send the file back in chunked mode. I had to enable the file type in the module though. AddOutputFilterByType DEFLATE image/png

See example:

curl --raw -v --header "Accept-Encoding: gzip, deflate" http://localhost/image.png | more
* Connected to localhost (127.0.0.1) port 80 (#0)
> GET /image.png HTTP/1.1
> User-Agent: curl/7.35.0
> Host: localhost
> Accept: */*
> Accept-Encoding: gzip, deflate
> 
< HTTP/1.1 200 OK
< Date: Mon, 13 Apr 2015 10:08:45 GMT
* Server Apache/2.4.7 (Ubuntu) is not blacklisted
< Server: Apache/2.4.7 (Ubuntu)
< Last-Modified: Mon, 13 Apr 2015 09:48:53 GMT
< ETag: "3b5306-5139805976dae-gzip"
< Accept-Ranges: bytes
< Vary: Accept-Encoding
< Content-Encoding: gzip
< Transfer-Encoding: chunked
< Content-Type: image/png
< 
Husein answered 13/4, 2015 at 10:12 Comment(0)
L
0

I tried this way to get HTTP chunked encoded data in Ubuntu, it might help.

In apache server create a file index.php in your directory where index page is there ( ex : /var/www/html/) and paste below content (should have php installed):

<?php phpinfo(); ?>

Then try to curl the page as below :

root@ubuntu-16:~# curl -v http://10.11.0.230:2222/index.php
*   Trying 10.11.0.230...
* Connected to 10.11.0.230 (10.11.0.230) port 2222 (#0)
> GET /index.php HTTP/1.1
> Host: 10.11.0.230:2222
> User-Agent: curl/7.47.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Wed, 01 Jul 2020 07:51:24 GMT
< Server: Apache/2.4.18 (Ubuntu)
< Vary: Accept-Encoding
< Transfer-Encoding: chunked
< Content-Type: text/html; charset=UTF-8
<
<!DOCTYPE html>
<html>
<body>
...
...
...
Levo answered 2/7, 2020 at 7:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.