feat: correct serialize of "bytes" data format

This commit is contained in:
2025-04-15 21:52:26 +02:00
parent 9c55ea257d
commit e9601b2fe1
4 changed files with 15 additions and 13 deletions

BIN
hsp-go

Binary file not shown.

View File

@ -15,6 +15,7 @@ func FileUploadRoute(req *server.Request) *server.Response {
log.Println("[MAIN] File Upload request:", req)
bytes, err := req.ExtractBytes()
if err != nil {
log.Fatalln("Failed to extract bytes from payload:", err)
return server.NewStatusResponse(server.STATUS_INTERNALERR)
}

View File

@ -1,2 +0,0 @@
Hello, everyone!
I'm a txt file

View File

@ -62,7 +62,11 @@ func (res *Response) ToPacket() *Packet {
maps.Copy(headers, res.Headers)
if res.Format.Format == DF_BYTES {
headers[H_DATA_FORMAT] = DF_BYTES
} else {
headers[H_DATA_FORMAT] = fmt.Sprintf("%s:%s", res.Format.Format, res.Format.Encoding)
}
headers[H_STATUS] = strconv.Itoa(res.StatusCode)
return BuildPacket(headers, res.Payload)
@ -87,4 +91,3 @@ func (res *Response) Write(p []byte) (int, error) {
return n, err
}