Code Monkey home page Code Monkey logo

Comments (9)

nhz2 avatar nhz2 commented on August 20, 2024 2

I think the issue is from

bytes = String(IOExtras.readuntil(io, find_end_of_header))

which calls:

HTTP.jl/src/IOExtras.jl

Lines 115 to 124 in efd74ea

function readuntil(buf::IOBuffer,
find_delimiter::F #= Vector{UInt8} -> Int =#
) where {F <: Function}
l = find_delimiter(view(buf.data, buf.ptr:buf.size))
if l == 0
return nobytes
end
bytes = view(buf.data, buf.ptr:buf.ptr + l - 1)
buf.ptr += l
return bytes

Since
JuliaLang/julia#53896

calling String on a view of a Memory and then trying to use the Memory is unsafe.

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}

from http.jl.

KristofferC avatar KristofferC commented on August 20, 2024 1

Yeah, I think all the uses of the IOBuffer internals has to be removed.

#1145 and #1147 has started that work.

from http.jl.

PhyX-Meow avatar PhyX-Meow commented on August 20, 2024

This is not the only issue with julia 1.11-beta, running pkg>test HTTP results in a very long list of errors.

from http.jl.

Westat-Transportation avatar Westat-Transportation commented on August 20, 2024

I am seeing a similar issue when processing the body of a POST request, see issue above on the Oxygen.jl repo for details.

from http.jl.

KristofferC avatar KristofferC commented on August 20, 2024

Does anyone have a simple repro for this?

from http.jl.

Westat-Transportation avatar Westat-Transportation commented on August 20, 2024

Server

using 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()

Client

using HTTP
HTTP.post("http://127.0.0.1:8080/login", body = "{ \"user_name\": \"test\" }")

from http.jl.

Westat-Transportation avatar Westat-Transportation commented on August 20, 2024

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)

from http.jl.

vtjnash avatar vtjnash commented on August 20, 2024

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

from http.jl.

quinnj avatar quinnj commented on August 20, 2024

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.

from http.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.