Skip to content

Support multipart/form-data #487

Open
@felipejoribeiro

Description

@felipejoribeiro

Prerequisites

  • I am using the latest stable release of Neovim
  • I am using the latest version of the plugin

Neovim Version

NVIM v0.10.2

Operating system/version

OS: Arch Linux x86_64 | Kernel: 6.11.4-arch2-1

Actual behavior

When executing the following http request:

POST /v1/image/
HOST: http://localhost:8000
X-AUTH: {{TOKEN}}
Content-Type: multipart/form-data; boundary=WebAppBoundary

--WebAppBoundary
Content-Disposition: form-data; name="file"; filename="logo.png"
< /entire/path/to/file/logo.png
--WebAppBoundary--

I receive the following response:

### v1-auth#49
POST http://localhost:8000/v1/image/
HTTP/1.1 400 Bad Request

# @_RES (formatted)
{
  "detail": "Empty content"
}
# @_END

The reason is that the data of the request is going empty, as shown in the debugging session (the server is being implemented in Django btw):

image

But the request follows the jetbrains guidelines, so i'm not sure if its not supported.

Expected behavior

The request should send the file to the server in the data object. Which is postman's behavior.

Steps to reproduce

Run the base project with repro with nvim -u repro.lua and then run the following test file with :Repo run:

POST /v1/image/
HOST: http://localhost:8000
X-AUTH: XXXXXXX
Content-Type: multipart/form-data; boundary=WebAppBoundary

--WebAppBoundary
Content-Disposition: form-data; name="file"; filename="logo.png"
< /entire/path/to/file/logo.png
--WebAppBoundary--

Other information

rest.nvim package version:
version 3.8.3
tag v3.8.3
branch main
commit 113dce7

*ps: thanks for the great plugin. Best regards.

Repro (lazy.nvim)

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
    spec = {
        "rest-nvim/rest.nvim",
        {
            "nvim-treesitter/nvim-treesitter",
            build = ":TSUpdate",
            main = "nvim-treesitter.configs",
            opts = {
                ensure_installed = { "http" },
                sync_install = false,
                highlight = { enable = true },
                indent = { enable = true },
            },
        },
    },
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions