💾 Archived View for gemi.dev › gemini-mailing-list › 000369.gmi captured on 2024-03-21 at 17:27:58. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-12-28)
-=-=-=-=-=-=-
An HTML attachment was scrubbed... URL: <https://lists.orbitalfox.eu/archives/gemini/attachments/20200910/a262 a090/attachment.htm>
Do you mean to throw away the first 8k of content bytes? Sent from phone On Thu, 10 Sep 2020, 14:14 Mr. Leveck, <sysop at 1436.ninja> wrote: > [repost in new thread] > > Greetings All! > > My www site has for sometime been displaying a homespun gopher proxy > (IE: my website displays my gopherhole). Since I recently installed a > gemini server on my home network, I wanted to expand my proxy to gemini > too. This is complete: https://leveck.us/gemini/1436.ninja/ > > I am having issues, however. With the gopher proxy, I hand binary files > over to curl via php after sending the appropriate header. Curl doesn't > currently support gemini, and I have been chasing my tail on getting > images (and binary files such as my RPoD Palm OS Software Horde) to work > with my proxy. > > Anyone got ideas? > > Here is the networky portion of the proxy source (line #s from vim): > 28 //Gemini Protocol Code > 29 //Nathaniel Leveck September 2020 > 30 $host = $host; > 31 $port = 1965; > 32 $cert = '/var/www/cert/cert.pem'; > 33 $context = stream_context_create(); > 34 stream_context_set_option($context, 'ssl', 'local_cert', $cert); > 35 stream_context_set_option($context, 'ssl', 'verify_peer', false); > 36 stream_context_set_option($context, 'ssl', 'verify_peer_name', false); > 37 stream_context_set_option($context, 'ssl', 'allow_self_signed', true); > 38 $socket = stream_socket_client('ssl://'.$host.':'.$port, $error, > $errorString, 2, > 39 STREAM_CLIENT_CONNECT, $context); > 40 fwrite($socket, "gemini://" . $url . "\r\n"); > 41 fread($socket,8192); //disregard the status + meta > 42 $content = fread($socket,8192000); //read a suitably large number of > bytes > > fread, I assume, is my issue. socketread showed me no love... > > -- > jynx > gopher://1436.ninja > gemini://1436.ninja > https://leveck.us > -------------- next part -------------- An HTML attachment was scrubbed... URL: <https://lists.orbitalfox.eu/archives/gemini/attachments/20200910/782f 980e/attachment.htm>
On 9/10/20 9:12 AM, Kevin Sangeelee wrote: > Do you mean to throw away the first 8k of content bytes? > > > Sent from phone Yes. All this does is toss out the status and meta data. I could specify 8MB to toss out, and the result would be the same in PHP using this method. This is alpha software. Later on I'll do something with the status and metadata, such as implement redirection, etc. Right now, I just want to figure out binary files... -- jynx gopher://1436.ninja gemini://1436.ninja https://leveck.us
Hi Mr. Leveck, On Thu, 10 Sep 2020 09:19:19 -0600 "Mr. Leveck" <leveck at leveck.us> wrote: > On 9/10/20 9:12 AM, Kevin Sangeelee wrote: > > Do you mean to throw away the first 8k of content bytes? > > > > > > Sent from phone > > Yes. > > All this does is toss out the status and meta data. I could specify > 8MB to toss out, and the result would be the same in PHP using this Perhaps you could use fgets($socket) instead, to read just the first line. The server might send the status + meta line in the same packet as the initial body data. In that case, reading just the first line with the buffered reader will save the rest of the body for later reading. -- Regards, Charles L. gemini://celehner.com/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 833 bytes Desc: OpenPGP digital signature URL: <https://lists.orbitalfox.eu/archives/gemini/attachments/20200910/9f1c 7aaa/attachment.sig>
On 9/10/20 9:28 AM, Charles E. Lehner wrote: > Hi Mr. Leveck, > > On Thu, 10 Sep 2020 09:19:19 -0600 > "Mr. Leveck" <leveck at leveck.us> wrote: > >> On 9/10/20 9:12 AM, Kevin Sangeelee wrote: >>> Do you mean to throw away the first 8k of content bytes? >>> >>> >>> Sent from phone >> >> Yes. >> >> All this does is toss out the status and meta data. I could specify >> 8MB to toss out, and the result would be the same in PHP using this > > Perhaps you could use fgets($socket) instead, to read just the first line. The server might send the status + meta line in the same packet as the initial body data. In that case, reading just the first line with the buffered reader will save the rest of the body for later reading. > I get all the content just fine... I am looking for advice on serving binary files via my proxy. -- jynx gopher://1436.ninja gemini://1436.ninja/ https://leveck.us
On Thu Sep 10, 2020 at 11:19 AM CEST, Mr. Leveck wrote: > On 9/10/20 9:12 AM, Kevin Sangeelee wrote: > > Do you mean to throw away the first 8k of content bytes? > > Yes. > > All this does is toss out the status and meta data. I could specify > 8MB > to toss out, and the result would be the same in PHP using this > method. I'm thinking you're going to toss out 8K which is probably much more than just the status and the meta data. fread is going to read past the \r\n terminating the status and it'll keep reading... and then you toss it all out. I think what you need to do is read everything, and then search and toss all the bytes up to the first \n or something like that. Cheers Alex
On 9/10/20 11:27 AM, Alex Schroeder wrote: > I'm thinking you're going to toss out 8K which is probably much more > than just the status and the meta data. fread is going to read past > the \r\n terminating the status and it'll keep reading... and then you > toss it all out. I think what you need to do is read everything, and > then search and toss all the bytes up to the first \n or something > like that. > > Cheers > Alex One would think, but that is not the case. Since everyone is hung up on that instead of my actual query, I have captured that initial status and now display it on the top of gemini:// pages on the proxy. Prior to that I was 100% successful in capturing all the document content the proxy code was requesting. All I have done now is assigned it to a var named $status and print that in a displayed page header. I am looking for advice on binary files. If anyone has any thoughts on that, it would be much appreciated. -- jynx gopher://1436.ninja gemini://1436.ninja/ https://leveck.us
Mr. Leveck, I looked into it more, comparing this broken image: https://leveck.us/gemini/1436.ninja/the_servers.png with the good original: gemini://1436.ninja/the_servers.png The proxied one has this header "<!-- GEMINI! --><!-- 1436.ninja/the_servers.png --><!-- 192.168.0.45 -->". That breaks the image. Also, in the content at byte 24576 (0x6000), the files diverge. The proxied one seems to restart sending the PNG image there, with some bytes missing. Maybe a variable is incorrectly set in your code? Charles On Thu, 10 Sep 2020 11:35:10 -0600 "Mr. Leveck" <leveck at leveck.us> wrote: > > > On 9/10/20 11:27 AM, Alex Schroeder wrote: > > > I'm thinking you're going to toss out 8K which is probably much more > > than just the status and the meta data. fread is going to read past > > the \r\n terminating the status and it'll keep reading... and then > > you toss it all out. I think what you need to do is read > > everything, and then search and toss all the bytes up to the first > > \n or something like that. > > > > Cheers > > Alex > > One would think, but that is not the case. Since everyone is hung up > on that instead of my actual query, I have captured that initial > status and now display it on the top of gemini:// pages on the proxy. > Prior to that I was 100% successful in capturing all the document > content the proxy code was requesting. All I have done now is > assigned it to a var named $status and print that in a displayed page > header. > > I am looking for advice on binary files. If anyone has any thoughts > on that, it would be much appreciated. > -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 833 bytes Desc: OpenPGP digital signature URL: <https://lists.orbitalfox.eu/archives/gemini/attachments/20200910/8bac a035/attachment.sig>
On 9/10/20 11:38 AM, Charles E. Lehner wrote: > Mr. Leveck, > > I looked into it more, comparing this broken image: > https://leveck.us/gemini/1436.ninja/the_servers.png > > with the good original: > gemini://1436.ninja/the_servers.png > > The proxied one has this header "<!-- GEMINI! --><!-- 1436.ninja/the_servers.png --><!-- 192.168.0.45 -->". That breaks the image. Also, in the content at byte 24576 (0x6000), the files diverge. The proxied one seems to restart sending the PNG image there, with some bytes missing. Maybe a variable is incorrectly set in your code? > > Charles Useful. The comments were added during troubleshooting something else. I think I have fixed all the above, but that image is still broken. I'll keep digging. -- jynx gopher://1436.ninja gemini://1436.ninja/ https://leveck.us
On 9/10/20 11:50 AM, Mr. Leveck wrote: > On 9/10/20 11:38 AM, Charles E. Lehner wrote: >> Mr. Leveck, >> >> I looked into it more, comparing this broken image: >> https://leveck.us/gemini/1436.ninja/the_servers.png >> >> with the good original: >> gemini://1436.ninja/the_servers.png >> >> The proxied one has this header "<!-- GEMINI! --><!-- >> 1436.ninja/the_servers.png --><!-- 192.168.0.45 -->". That breaks the >> image. Also, in the content at byte 24576 (0x6000), the files diverge. >> The proxied one seems to restart sending the PNG image there, with >> some bytes missing. Maybe a variable is incorrectly set in your code? >> >> Charles This led me to it. Thank you very much! New code: status = stream_get_line($socket,512,"\r\n"); content = stream_get_contents($socket); The first line strips off 512 bytes, or until \r\n is encountered. The second is much better for my intended use than fread at acquiring the rest. Binary files now work. Now I need to iron out some other things like relative URLs... -- jynx gopher://1436.ninja gemini://1436.ninja/ https://leveck.us
---