[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Stream error in framing layer


On Fri, 2 Aug 2024 at 13:19, BB <adamnt42@xxxxxxxxx> wrote:

> I use a JSON download via httpclient to retrieve some live data.
> Recently I have been getting a consistent failure with the heading
> "error". This error, according to the internet pundits is something to
> do with the server doing http2 badly.
>
> Their answer is to force curl (via httpclient) to use headers to force
> the server to reply in http1.1
>
> It seems that I need to set some header to use the value
> "CURL_HTTP_VERSION_1_1" somehow. I have not been able to work out how to
> this, so has anyone got any clues?
>
> tia
>
> b
>

I recently figured out my own way to respond a HTTP requests.

I did some research and found a http response typically has a specific
format for line 1 the the data comes after the first CRLF.
So my first line is this...
HTTP/1.1 200 OK\r\n

That tells the HTTP response format is version 1.1 code 200 and msg OK,
(not sure if that's the solution you need)

This is my code that makes a HTTP1.1 html reply and also does favicon...
(sTxt is from the Socket_Read event)

  If sTxt Begins "GET / HTTP/1.1" Then
    sTxt = MakeHtml(Last)  ' make the html body.

    Print #Last, "HTTP/1.1 200 OK\r\n<!DOCTYPE html>\r\n\r\n<HTML><BODY>" &
sTxt & "</BODY></HTML>"
    Last.Close
    Return

  Else If sTxt Begins "GET /favicon.ico HTTP/1.1" Then
    sTxt = File.Load("./icon.png")
    Write #Last, sTxt, String.Len(sTxt)
    Last.Close
Endif

References:
Stream error in framing layerBB <adamnt42@xxxxxxxxx>