bugMIT/GNU Scheme - Bugs: bug #62581, write-http-response procedure is...

 
 

bug #62581: write-http-response procedure is broken

Submitter:  - <_314975>
Submitted:  Sat 04 Jun 2022 06:07:45 AM UTC
   
 
Category:  runtime Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect behavior
Status:  Fixed Privacy:  Public
Assigned to:  cph Originator Name: 
Open/Closed:  Closed
Keywords: 
* Mandatory Fields

Add a New Comment Rich Markup
   

Sat 04 Jun 2022 06:07:45 AM UTC, original submission:  

(let* ((socket (open-tcp-server-socket 8000))
       (port (tcp-server-connection-accept socket #t #f))
       (response (make-http-response (make-http-version 1 1) 200 "OK" '()
                                     (string->utf8 "Hello!"))))
  (write-http-response response port))

When the code above is run, and I connect to localhost:8000 using a web browser, `write-http-response` will fail with this error:

;The object #[textual-i/o-port 12 for channel: #[channel 13]], passed as an argument to #[compiled-procedure 14 ("binary-port" #x3) #x1c #x29ce984], is not the correct type.

So, I changed `tcp-server-connection-accept` to `tcp-server-binary-connection-accept`:

(let* ((socket (open-tcp-server-socket 8000))
       (port (tcp-server-binary-connection-accept socket #t #f))
       (response (make-http-response (make-http-version 1 1) 200 "OK" '()
                                     (string->utf8 "Hello!"))))
  (write-http-response response port))

When I connect to localhost:8000, there will also be an error:

;The object #[binary-i/o-port 12], passed as an argument to write-char, is not the correct type.

This error is caused by `(newline port)` in `write-http-response` [1]. The `newline` procedure can only accept a textual port, not a binary port. A similar problem exists in the `write-http-request` procedure, so you may want to fix that too.


[1]: https://git.savannah.gnu.org/cgit/mit-scheme.git/tree/src/runtime/http-io.scm?h=release-11.2#n191

- <_314975>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by cph (Updated the item)
  • -email is unavailable- added by _314975 (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-09-05 cph StatusNone Fixed
        Assigned toNone cph
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code