Coder Social home page Coder Social logo

netbuf's People

Contributors

alreece45 avatar c4k3 avatar popravich avatar pyfisch avatar tailhook avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

netbuf's Issues

Async response

struct HelloWorld;

impl<C:Counter> rotor_http::http1::Handler<C> for HelloWorld {
    fn request(req: rotor_http::http1::Request,
               res: &mut rotor_http::http1::ResponseBuilder,
               ctx: &mut C)
    {

        println!("request");

        ctx.increment();
        match req.uri {
            hyper::uri::RequestUri::AbsolutePath(ref p) if &p[..] == "/" => {

                thread::spawn(move || {

                    res.set_status(hyper::status::StatusCode::Ok);

                    let five_seconds = time::Duration::new(5, 0);
                    thread::sleep(five_seconds);
                    res.put_body("Hello World!");
                });    
            }

            hyper::uri::RequestUri::AbsolutePath(ref p) if &p[..] == "/num"
            => {
                res.set_status(hyper::status::StatusCode::Ok);
                res.put_body(format!("This host visited {} times",
                                     ctx.get()));
            }
            hyper::uri::RequestUri::AbsolutePath(p) => {
                res.set_status(hyper::status::StatusCode::Ok);
                res.put_body(format!("Hello {}!", &p[1..]));
            }

            _ => {}  // Do nothing: not found or bad request
        }
    }
}

Is it possible to delay sending a response?
This could be useful if waiting for a response from the database.

Currently I getting errors :

examples/threaded.rs:41:5: 41:18 error: the type `[closure@examples/threaded.rs:41:19: 48:8 res:&mut rotor_http::http1::ResponseBuilder<'_, '_>]` does not fulfill the required lifetime [E0477]
examples/threaded.rs:41                 thread::spawn(move || {
                                        ^~~~~~~~~~~~~
note: type must outlive the static lifetime
examples/threaded.rs:41:5: 41:18 error: the type `[closure@examples/threaded.rs:41:19: 48:8 res:&mut rotor_http::http1::ResponseBuilder<'_, '_>]` does not fulfill the required lifetime [E0477]
examples/threaded.rs:41                 thread::spawn(move || {
                                        ^~~~~~~~~~~~~
note: type must outlive the static lifetime
examples/threaded.rs:41:5: 41:18 error: the type `[closure@examples/threaded.rs:41:19: 48:8 res:&mut rotor_http::http1::ResponseBuilder<'_, '_>]` does not fulfill the required lifetime [E0477]
examples/threaded.rs:41                 thread::spawn(move || {
                                        ^~~~~~~~~~~~~
note: type must outlive the static lifetime
error: aborting due to 3 previous errors
Could not compile `rotor-http`.

Remove MAX_BUF_SIZE limitations

I'm currently working on a AMQP client, the maximum theoretical size for a frame is 2^32-- slightly over what netbuf allows.

I was thinking of writing a fix, but am wondering on what would be the most acceptable solution.

  1. 2 structures, Buf and UnboundBuf-- UnboundBuf does most of the work, but Buf ensures that the capacity remains less than MAX_BUF_SIZE.
  2. Like above, but instead of hard-coding the maximum buffer size, have it configurable.
  3. 1 structure, but the functionality of MAX_BUF_SIZE toggled off with a feature (or toggled on by removing a default feature).

Thoughts?

compile error in netbuf v0.2.0

I try run "rotor-http" example file.

When compiling get an error :

grzegorz@grzegorz:~/Pulpit/rotor-http$ cargo run --example threaded --verbose
    Updating registry `https://github.com/rust-lang/crates.io-index`
    Updating git repository `git://github.com/tailhook/rotor`
       Fresh unicase v1.0.1
       Fresh slab v0.1.2
       Fresh httparse v1.0.0
       Fresh bytes v0.2.11
       Fresh gcc v0.3.19
       Fresh libc v0.1.12
       Fresh traitobject v0.0.1
       Fresh language-tags v0.0.7
       Fresh log v0.3.3
       Fresh mime v0.1.0
       Fresh hpack v0.2.0
       Fresh solicit v0.4.4
       Fresh winapi v0.2.5
       Fresh bitflags v0.3.3
       Fresh matches v0.1.2
       Fresh libc v0.2.2
       Fresh memchr v0.1.7
       Fresh winapi v0.1.23
       Fresh bitflags v0.1.1
   Compiling nix v0.3.9
     Running `rustc /home/grzegorz/.cargo/registry/src/github.com-121aea75f9ef2ce2/nix-0.3.9/src/lib.rs --crate-name nix --crate-type lib -g -C metadata=1295479b75f240b4 -C extra-filename=-1295479b75f240b4 --out-dir /home/grzegorz/Pulpit/rotor-http/target/debug/deps --emit=dep-info,link -L dependency=/home/grzegorz/Pulpit/rotor-http/target/debug/deps -L dependency=/home/grzegorz/Pulpit/rotor-http/target/debug/deps --extern bitflags=/home/grzegorz/Pulpit/rotor-http/target/debug/deps/libbitflags-83dc6fc5ecc9dd71.rlib --extern libc=/home/grzegorz/Pulpit/rotor-http/target/debug/deps/liblibc-6bc3b8388045ae15.rlib --cap-lints allow`
       Fresh lazy_static v0.1.15
   Compiling netbuf v0.2.0
     Running `rustc /home/grzegorz/.cargo/registry/src/github.com-121aea75f9ef2ce2/netbuf-0.2.0/src/lib.rs --crate-name netbuf --crate-type lib -g -C metadata=f13fe0a853c39504 -C extra-filename=-f13fe0a853c39504 --out-dir /home/grzegorz/Pulpit/rotor-http/target/debug/deps --emit=dep-info,link -L dependency=/home/grzegorz/Pulpit/rotor-http/target/debug/deps -L dependency=/home/grzegorz/Pulpit/rotor-http/target/debug/deps --cap-lints allow`
/home/grzegorz/.cargo/registry/src/github.com-121aea75f9ef2ce2/netbuf-0.2.0/src/buf.rs:13:34: 13:41 error: attempted left shift with overflow
/home/grzegorz/.cargo/registry/src/github.com-121aea75f9ef2ce2/netbuf-0.2.0/src/buf.rs:13 pub const MAX_BUF_SIZE: usize = (1 << 32) - 2;
                                                                                                                           ^~~~~~~
error: aborting due to previous error
Could not compile `netbuf`.

Caused by:
  Process didn't exit successfully: `rustc /home/grzegorz/.cargo/registry/src/github.com-121aea75f9ef2ce2/netbuf-0.2.0/src/lib.rs --crate-name netbuf --crate-type lib -g -C metadata=f13fe0a853c39504 -C extra-filename=-f13fe0a853c39504 --out-dir /home/grzegorz/Pulpit/rotor-http/target/debug/deps --emit=dep-info,link -L dependency=/home/grzegorz/Pulpit/rotor-http/target/debug/deps -L dependency=/home/grzegorz/Pulpit/rotor-http/target/debug/deps --cap-lints allow` (exit code: 101)

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.