Hello MIT/GNU Scheme developers,

I am having some issues trying to get http-get to work. For some URLs it works:

(define response (http-get "http://hydrant.mit.edu/latestTerm.json"; '()))
(utf8->string (http-response-body response))
;Value: "{\n  \"preSemester\": {\n    \"urlName\": \"i25\",\n \"startDate\": \"2025-01-06\",\n    \"endDate\": \"2025-01-31\",\n    \"holidayDates\": [\n \"2025-01-20\"\n    ]\n  },\n  \"semester\": {\n    \"urlName\": \"s25\",\n    \"startDate\": \"2025-02-03\",\n    \"h1EndDate\": \"2025-03-21\",\n    \"h2StartDate\": \"2025-03-31\",\n \"endDate\": \"2025-05-13\",\n    \"mondayScheduleDate\": \"2025-02-18\",\n    \"holidayDates\": [\n \"2025-02-17\",\n      \"2025-03-24\",\n \"2025-03-25\",\n      \"2025-03-26\",\n \"2025-03-27\",\n      \"2025-03-28\",\n \"2025-04-21\"\n    ]\n  }\n}\n"

However, for other URLs it does not work:

(http-get "http://127.0.0.1:10002/_matrix/client/v3/login"; '())
;The object #[binary-output-port 12], passed as an argument to write, is not the correct type.
;To continue, call RESTART with an option number:
; (RESTART 1) => Return to read-eval-print level 1.
;Start debugger? (y or n): y

I am attaching the output I got from the Edwin debugger. Please let me know what additional information I can provide to you so we can troubleshoot, and so that I can provide a bug report.

Thanks a lot in advance, and wishing you a good day.

Best,
Gabriel

*edwin debugger:*

The error that started the debugger is:

  The object #[binary-output-port 12], passed as an argument to write, is not the correct type.

>S0  (if (not (textual-output-port? #[uninterned-symbol 13 object])) (error ...
 S1  (optional-output-port port caller)
 S2  (procedure port)
 S3  (call-with-output-bytevector (lambda (port) ((%record-ref defn 4) valu ...  S4  (make-http-header (quote host) (let ((authority (uri-authority uri)))  ...
 S5  ((car ops) method uri headers)
 S6  (add-default-headers method uri headers)
 S7  (http-client-request method uri headers body)
    R0  (http-get "http://127.0.0.1:10002/_matrix/client/v3/login"; (quote ( ...
 S8  ;unknown compiled code
 --more--


--%%-Edwin: *debug* (Debug)----Bot-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
                         SUBPROBLEM LEVEL: 0

COMPILED expression (from stack):
 Subproblem being executed is highlighted.

    (begin (if (not (textual-output-port? object)) (error:not-a textual-output-port? object caller)) object)

---------------------------------------------------------------------
ENVIRONMENT named: ()
    has 5402 bindings

  ENVIRONMENT named: (runtime)
      has 174 bindings

    ENVIRONMENT named: (runtime output-port)
        has 58 bindings

  ==> ENVIRONMENT created by a LET special form

          #[uninterned-symbol 13 object] = #[binary-output-port 12]
          #[uninterned-symbol 15 caller] = write

*Other non-Scheme information:*

Additionally, this works fine on curl:

$ curl -v http://127.0.0.1:10002/_matrix/client/v3/login
*   Trying 127.0.0.1:10002...
* Connected to 127.0.0.1 (127.0.0.1) port 10002
> GET /_matrix/client/v3/login HTTP/1.1
> Host: 127.0.0.1:10002
> User-Agent: curl/8.9.1
> Accept: */*
>
* Request completely sent off
< HTTP/1.1 200 OK
< Server: nginx/1.18.0 (Ubuntu)
< Date: Sun, 20 Apr 2025 03:01:01 GMT
< Content-Type: application/json
< Transfer-Encoding: chunked
< Connection: keep-alive
< Cache-Control: no-cache, no-store, must-revalidate
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Methods: GET, HEAD, POST, PUT, DELETE, OPTIONS
< Access-Control-Allow-Headers: X-Requested-With, Content-Type, Authorization, Date
< Access-Control-Expose-Headers: Synapse-Trace-Id, Server
<
* Connection #0 to host 127.0.0.1 left intact
{"flows":[{"type":"m.login.sso","identity_providers":[{"id":"saml","name":"Touchstone"}]},{"type":"m.login.token"},{"type":"m.login.password"},{"type":"m.login.application_service"}]}

The reason why I am using localhost, is because I could not find anything about SSL or HTTPS in the documentation and (apropos 'ssl) and (apropos 'https) yielded no results, so I am using stunnel to allow connecting via HTTP. This is my stunnel.conf:

foreground = yes
debug = info

[matrix]
client = yes
accept = 127.0.0.1:10002
connect = matrix-synapse.mit.edu:443
checkHost = matrix-synapse.mit.edu
verifyChain = yes
OCSPaia = yes
CApath = /etc/ssl/certs

Reply via email to