HTTP multipart/form-data processing by server


Is any way to parse multipart/form-data by HTTP functions?

I’m trying to upload and process a file in Bukdu app with

  <form method="post" enctype="multipart/form-data">...</form>

The request.body is correct for multipart. But I don’t see any way to convert it to HTTP.Multipart. The are only client related methods at

Should I implement that functionality self? Or may be it is already implemented somewhere? Any ideas why it is not inside HTTP?

I’m talking about a body like:

Content-Disposition: form-data; name=\"image\"; filename=\"1.png\"\r\nContent-Type: image/png

Workaround for now (it is working at least in my demo app):

import HTTP, HTTP.Parsers
  returns embedded data or nothing
function parse_multipart(data::Vector{UInt8})
    chunk_end = HTTP.Parsers.find_end_of_chunk_size(data)
    if chunk_end == 0
        return nothing

    boundary = data[1:chunk_end - 2] # should be without \r\n
    header_end = HTTP.Parsers.find_end_of_header(data)

    data_start = header_end + 1
    data_end = length(data) - chunk_end - 2
    # check that block ending is with same boundary + two additional hyphens
    if (data[data_end + 1: end] == [boundary..., 0x2d, 0x2d, 0x0d, 0x0a])
       return data[data_start : data_end]

    return nothing

data = parse_multipart(c.conn.request.body)

Looks like there is a pull request with similar function but still not merged into HTTP -