💾 Archived View for gem.graypegg.com › gor › connections captured on 2023-04-26 at 12:55:54. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-01-29)

-=-=-=-=-=-=-

🎍 Gray's Space (Root)

<-- Back

Turn on syntax highlighting

Connections

represent the current connection to the client, and are generally something you won't have to deal with except inside implementations of Persistent#on_conncetion.

See Persistent

API

Connection#request

conn.request

The request from the client, as parsed by Ruby's URI module. Gemini clients only send a URI to servers, so this is all the information we have about the client.

See Ruby Docs on URI

Connection#body= / Connection#body

conn.body = 'Hi'
conn.body

Sets or gets the current body that will be sent when this transaction completes. The body can be anything textual, but no binary data is allowed.

Connection#mime_type= / Connection#mime_type

conn.mime_type = 'text/plain'
conn.mime_type

Sets or gets the current body that will be sent when this transaction completes. The body can be anything textual, but no binary data is allowed.

Connection#status= / Connection#status

conn.status = 51
conn.status

Sets or gets the current Gemini status code that will be sent when this transaction completes. This should be an integer.

See Gemini spec, Section 3.2 Status codes

Connection#send

conn.send

Sends the current body + status for this connection to the client, and closes the connection. Note that you can only send once, and future calls to send on this connection will do nothing. This allows you to stub connections in a presistent if you'd like.

Connection#started_at

conn.started_at

Timestamp of when this connection was initially processed. It's a standard Ruby Time object

Connection#source_ip

conn.source_ip

The originating IP for this connection in a string. Useful for IP blocking.