| Posted: 05:49pm 26 May 2026 |
Copy link to clipboard |
 Print this post |
|
The old request was malformed but the previous TLS stack was lenient enough to let it through. The new mbedTLS path needs a proper HTTP/1.1 request — specifically a CRLF (not LF+CR), an HTTP/1.1 version token, a Host: header, and a blank line terminator. Note the b$ lines will need connecting together.
Dim buff%(8192/8) Dim CRLF$ = Chr$(13) + Chr$(10) Dim b$ = "GET /api/v1/prices/2026/05-26_SE4.json HTTP/1.1" + CRLF$ + "Host: _ www.elprisetjustnu.se" + CRLF$ + "User-Agent: WebMite" + CRLF$ + "Accept: _ application/json" + CRLF$ + "Connection: close" + CRLF$ + CRLF$
WEB OPEN TLS CLIENT "www.elprisetjustnu.se", 443 WEB TCP CLIENT REQUEST b$, buff%(), 10000 LongString print buff%() Pause 1000 WEB CLOSE TCP CLIENT
Key points vs. your original:
CRLF order: HTTP requires \r\n (Chr$(13)+Chr$(10)), your code had them reversed. HTTP version: must include HTTP/1.1 after the path. Host header: mandatory in HTTP/1.1 and required by virtual-hosted servers like this one; without it you'll usually get a 400. Blank line: a request ends with an extra CRLF on its own. Connection: close: makes the server close after responding so your buffer/timeout behavior is predictable. Fixed the Wwww typo and the smart quotes (” → ") — those would also fail to compile as-is. |