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

Upload large content & callbacks #15

Open
edsiper opened this issue Jun 8, 2014 · 1 comment
Open

Upload large content & callbacks #15

edsiper opened this issue Jun 8, 2014 · 1 comment

Comments

@edsiper
Copy link
Member

edsiper commented Jun 8, 2014

Duda stack should support an API to allow the server to listen for large data uploads, where Monkey server after receive the HTTP request headers (on PUT/POST), let Duda handle each incoming data frame.

The API should be something like this:

map->static_upload_stream("/upload", int (*callback)(struct duda_request *dr,  void* buffer, ssize_t len));

so all POST/PUT request with content length > 0 that arrives over /upload URI, will be handled by the callback function which also sets a buffer and a size, that function will be invoked many times until the upload is complete or for some reason the connection is closed.

@nalbeza
Copy link

nalbeza commented Jun 10, 2014

Steps to implement feature

This comment is a work in progress.

Monkey

  • Modify HTTP parser to allow stream parsing (maybe use something like Ragel ?)

    Ex:

    parser->request_line_cb = ...;
    parser->header_read_cb = ...;
    void parse_input_data(parser_ctx_t* parser, session_request* sr, void* data, size_t len);

    Or just wait for block end and parse whole header block at once

  • Add necessary API hooks (placeholder names)

    • on_headers_ready
      Could be used to authenticate request before body is sent (fail early), or setup body streaming
      Must expose an API to enable body chunk callback
      Return value actions:
      • Abort connection, error response
      • Continue, read request body
    • on_body_chunk_read
      Receives read body chunks.
      Return value actions:
      • Abort connection, error response
      • Chunk handled, buffered data can be discarded
      • Chunk handled, continue to buffer data
  • Find all code that expects whole request buffered and work around that

Duda

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