-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Character lost in HTTP post response body. #1166
Comments
This is not the only issue with julia 1.11-beta, running |
I am seeing a similar issue when processing the body of a POST request, see issue above on the Oxygen.jl repo for details. |
Does anyone have a simple repro for this? |
Serverusing Oxygen
using HTTP
using StructTypes
struct Login
user_name::String
end
@post "/login" function(req::HTTP.Request)
@info req.body
login_data = json(req, Login)
@info login_data
return "hello world!"
end
# start the web server
serve() Clientusing HTTP
HTTP.post("http://127.0.0.1:8080/login", body = "{ \"user_name\": \"test\" }") |
You can see what the exception that Client call generates on the Server while running on Julia 1.11 here -> OxygenFramework/Oxygen.jl#186 (comment) |
I think the issue is from Line 533 in efd74ea
which calls: Lines 115 to 124 in efd74ea
Since calling Here is a example: julia> a = Memory{UInt8}(undef, 10);
julia> fill!(a, 0x01);
julia> String(view(a, 1:2))
"\x01\x01"
julia> a
0-element Memory{UInt8} |
In theory, a normal readbyte call there could allocate a StringVector more directly here, avoiding the copy later to make a String from this, and avoid relying on implementation details too |
I agree we need to refactor a bunch of the internals to not abuse IOBuffer; either move everything to be Memory-based (my preference since we'll have full control and want to be efficient as possible w/ # of allocations), or just use IOBuffer's properly. In any case, I think #1170 is at least a stop-gap for the immediate issue posted here. |
Versions:
I have a HTTP server running locally, but querying the server using HTTP.post give me this:
The response body is missing the first character, in my case, the beginning
{
in json string is lost.Correct result should look like this curl result:
The issue happens today when I updated julia version.
The text was updated successfully, but these errors were encountered: