Giter VIP home page Giter VIP logo

Comments (7)

ashtum avatar ashtum commented on May 18, 2024

You can utilize a http::buffer_body and a fixed size buffer for that purpose, these examples might help:
https://www.boost.org/doc/libs/1_84_0/libs/beast/doc/html/beast/more_examples/http_relay.html
https://www.boost.org/doc/libs/1_84_0/libs/beast/doc/html/beast/using_http/parser_stream_operations/incremental_read.html

from beast.

vinniefalco avatar vinniefalco commented on May 18, 2024

file_body can do exactly what you say

from beast.

ashtum avatar ashtum commented on May 18, 2024

file_body can do exactly what you say

If I understand correctly, they want to use boost::asio::stream_file and perform the write operation asynchronously.

from beast.

meastp avatar meastp commented on May 18, 2024

@vinniefalco @ashtum I don't need async write operation. If I understand file_body correctly, it is only the body content that is serialized to file, while I need the entire request serialized to a single file. Is my understanding of file_body correct?

I'm trying the HTTP Relay example now, it does look like exactly what I'm after, but if there are simpler/better/more efficient solutions I'd love to learn about them :)

from beast.

vinniefalco avatar vinniefalco commented on May 18, 2024

You want your file to have the HTTP headers?

from beast.

meastp avatar meastp commented on May 18, 2024

@vinniefalco Well, yes I do. Serializing the whole request to a single file for later processing instead of spreading it across multiple files makes it a bit easier to keep track. I might change it, but it's what I currently do. The HTTP Relay example was perfect - thanks @ashtum :)

from beast.

vinniefalco avatar vinniefalco commented on May 18, 2024

No the relay example is not perfect. If you want the HTTP headers in the file then you should do the following:

  1. read the header
  2. write the header to a new file yourself
  3. read the rest of the body, appending into the new file using file_body with a single call to http::async_read

Thanks

from beast.

Related Issues (20)

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.