Jump to content

How do I generate a CHUNKED reply to a GET in PHP / Apache?


markosjal

Recommended Posts

I am working on an http interface to existing apps. These apps make a call to GET a CHUNKED reply with the payload being a Jpg (or series of jpg??) , or a single pdf file

 

The wireshark trace looks like this:

Frame 1093: 209 bytes on wire (1672 bits), 209 bytes captured (1672 bits) on interface \Device\NPF_{9AF84BC1-E1F6-4A31-BC25-33964BBB83EC}, id 0
Ethernet II, Src: Motorola_18:69:75 (84:b8:b8:18:69:75), Dst: IntelCor_f8:a5:5c (a4:34:d9:f8:a5:5c)
Internet Protocol Version 4, Src: 192.168.0.150, Dst: 192.168.0.99
Transmission Control Protocol, Src Port: 35138, Dst Port: 8000, Seq: 14994, Ack: 122074, Len: 155
Hypertext Transfer Protocol
    GET /eSCL/ScanJobs/NextDocument HTTP/1.1\r\n
    TE: chunked\r\n
    Host: 192.168.0.99:8000\r\n
    Connection: Keep-Alive\r\n
    Accept-Encoding: gzip\r\n
    User-Agent: okhttp/4.9.1\r\n
    \r\n
    [Full request URI: http://192.168.0.99:8000/eSCL/ScanJobs/NextDocument]
    [HTTP request 98/101]
    [Prev request in frame: 1091]
    [Response in frame: 1094]
    [Next request in frame: 1095]

Then I see this in Wireshark, but nothing is ever downloaded the request is made over and over till cancelled:

Frame 1094: 1319 bytes on wire (10552 bits), 1319 bytes captured (10552 bits) on interface \Device\NPF_{9AF84BC1-E1F6-4A31-BC25-33964BBB83EC}, id 0
Ethernet II, Src: IntelCor_f8:a5:5c (a4:34:d9:f8:a5:5c), Dst: Motorola_18:69:75 (84:b8:b8:18:69:75)
Internet Protocol Version 4, Src: 192.168.0.99, Dst: 192.168.0.150
Transmission Control Protocol, Src Port: 8000, Dst Port: 35138, Seq: 122074, Ack: 15149, Len: 1265
Hypertext Transfer Protocol
    HTTP/1.1 200 OK\r\n
    Date: Tue, 13 Jul 2021 11:12:43 GMT\r\n
    Server: Apache/2.4.48 (Win64) OpenSSL/1.1.1k PHP/8.0.8\r\n
    Content-Length: 1038\r\n
    Keep-Alive: timeout=5, max=3\r\n
    Connection: Keep-Alive\r\n
    Content-Type: text/html;charset=UTF-8\r\n
    \r\n
    [HTTP response 98/101]
    [Time since request: 0.005202000 seconds]
    [Prev request in frame: 1091]
    [Prev response in frame: 1092]
    [Request in frame: 1093]
    [Next request in frame: 1095]
    [Next response in frame: 1096]
    [Request URI: http://192.168.0.99:8000/eSCL/ScanJobs/NextDocument]
    File Data: 1038 bytes
Line-based text data: text/html (16 lines)
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">\n
    <html>\n
     <head>\n
      <title>Index of /eSCL/ScanJobs/NextDocument</title>\n
     </head>\n
     <body>\n
    <h1>Index of /eSCL/ScanJobs/NextDocument</h1>\n
      <table>\n
       <tr><th valign="top"><img src="/icons/blank.gif" alt="[ICO]"></th><th><a href="?C=N;O=D">Name</a></th><th><a href="?C=M;O=A">Last modified</a></th><th><a href="?C=S;O=A">Size</a></th><th><a href="?C=D;O=A">Description</a></th></tr>\n
       <tr><th colspan="5"><hr></th></tr>\n
    <tr><td valign="top"><img src="/icons/back.gif" alt="[PARENTDIR]"></td><td><a href="/eSCL/ScanJobs/">Parent Directory</a>       </td><td>&nbsp;</td><td align="right">  - </td><td>&nbsp;</td></tr>\n
    <tr><td valign="top"><img src="/icons/text.gif" alt="[TXT]"></td><td><a href="index.php">index.php</a>              </td><td align="right">2021-07-13 00:43  </td><td align="right">1.0K</td><td>&nbsp;</td></tr>\n
       <tr><th colspan="5"><hr></th></tr>\n
    </table>\n
    <address>Apache/2.4.48 (Win64) OpenSSL/1.1.1k PHP/8.0.8 Server at 192.168.0.99 Port 8000</address>\n
    </body></html>\n

 

So how do I get Apache/PHP to respond to this GET CHUNKED request in a way the client understands?

 

Edited by markosjal
Link to comment
Share on other sites

  • markosjal changed the title to How do I generate a CHUNKED reply to a GET in PHP / Apache?

Looks to me like Apache is doing exactly what it's supposed to be doing and that okhttp is the one at fault.

TE specifies support for transfer encodings in the response. TE must never include "chunked", but okhttp is doing that.

TE is also optional in that a response may not use any transfer encoding at all, as Apache is doing there, but okhttp isn't respecting that and/or your problem is due to something else.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.