Skip to content

malai http bridge, post not working #63

@amitu

Description

@amitu

As reported by @TanishqSingla:

GET requests are working fine.

However POST requests that contain request body often gets stuck, I am not sure if this an issue with the client (in my case the client is discord).

After adding timeouts, I am able to not get stuck during the second request

r.Body = http.MaxBytesReader(w, r.Body, 1048576) // 1MB limit

if conn, ok := r.Body.(interface{ SetReadDeadline(t time.Time) error }); ok {
	conn.SetReadDeadline(time.Now().Add(10 * time.Second))
}

body, err := io.ReadAll(r.Body)
defer r.Body.Close()
if err != nil {
	w.WriteHeader(http.StatusBadRequest)
	w.Write([]byte("{\"status\": \"error reading body\"}"))
	return
}

But this results in this error:

Location:
    /Users/runner/work/kulfi/kulfi/kulfi-utils/src/peer_to_http.rs:87:5
2025-05-20T12:24:13.748938Z ERROR kulfi_utils::peer_to_http: no request
2025-05-20T12:24:13.748987Z ERROR malai::expose_http: failed to proxy http: no request

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions