Skip to content
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

Expect request header does not work with custom handler for PUT in ejabberd_http #3434

Open
steve-vsee opened this issue Dec 2, 2020 · 3 comments

Comments

@steve-vsee
Copy link

Environment

  • ejabberd version: 20.07
  • Erlang version: Erlang/OTP 22
  • OS: MacOS/CentOS
  • Installed from: source

Configuration (only if needed): grep -Ev '^$|^\s*#' ejabberd.yml

Errors from error.log/crash.log

Bug description

When a PUT is requested with an HTTP expect HEADER, no data is passed to the request handler. The problem appears to be in ejabberd_http:extract_path_query where PUT and POST are handled differently. The problem can be seen put sending a PUT request via curl (on CLI) with a payload > 1k.

@badlop
Copy link
Member

badlop commented Dec 4, 2020

Can you update your ticket to provide all the information (changes in the source code, configuration, curl queries, steps) required to reproduce the problem?

@steve-vsee
Copy link
Author

steve-vsee commented Dec 8, 2020

mod_put_bug.erl:

-module(mod_put_bug).
-behavior(gen_mod).

-export([
    start/2, 
    stop/1,
    process/2,  depends/2, mod_doc/0, mod_options/1
    ]).
-include("logger.hrl").
-include("ejabberd_http.hrl").
-include("translate.hrl").
%%% Module Init
%
start(_Host, _Opts) -> 
  ok.    
%%% Module Terminate
%
stop(_Host) ->
  ok.

depends(_Host, _Opts) ->  
    [].

mod_doc() ->
     #{desc => [?T("")]}.

mod_options(_Host) -> [].

process(_Path, Request) ->
    #request{ data = Data } = Request,
    ?DEBUG("Data length ~p", [byte_size(Data)]),
    {200,
    [],
    "200 OK"}.

ejabberd.yml addition :

listen:
  -
    port: 8888
    ip: "::"
    module: ejabberd_http
    request_handlers:
      /put_bug : mod_put_bug

curl that works:

curl -v -s -X PUT http://localhost:8888/put_bug --data '0123456789'

curl that fails:

curl -v -s -X PUT http://localhost:8888/put_bug --data '012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'

You can see that in the DEBUG message for the failing PUT, the module doesn't get any data from ejabberd_http.

Let me know if you need any more info, or if there is something wrong with my code. Thanks.

@badlop
Copy link
Member

badlop commented Dec 16, 2020

Right, the problem is reproducible with Curl. I tested mod_http_upload, and the Gajim client can upload large files using PUT, by not using Expect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants