Closed azmathmoosa closed 6 years ago
this worked
conn->response().add("Content-Length", "0");
conn->response().add("Connection", "close"); // "keep-alive"
conn->sendHeader();
but there is still no documentation for File uploads, POST parsing etc. Can you guide me pls?
Sorry about the lack of examples for the HTTP implementation! The best source is the tests file: https://github.com/sourcey/libsourcey/blob/master/src/http/tests/httptests.cpp
The HTTP module is used extensively throughout libsourcey so you can also do a code search for http:: in order to get find code samples.
Hope this helps!
On 9 February 2018 at 07:24, azmathmoosa notifications@github.com wrote:
this worked
conn->response().add("Content-Length", "0"); conn->response().add("Connection", "close"); // "keep-alive" conn->sendHeader();
but there is still no documentation for File uploads, POST parsing etc. Can you guide me pls?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sourcey/libsourcey/issues/219#issuecomment-364346594, or mute the thread https://github.com/notifications/unsubscribe-auth/AAGKDI15dZy3DFlC3ACpYQlUo3B4QBR9ks5tS-SNgaJpZM4R93cC .
Thanks, I managed to get upto this
srv.Connection += [&](http::ServerConnection::Ptr conn) {
//string endpoint = resolve_api_endpoint(conn);
NVCollection flagParams;
conn->request().getURIParameters(flagParams);
for(auto it=flagParams.begin(); it!=flagParams.end(); it++){
cout << it->first << ":" << it->second << endl;
}
conn->Payload += [](http::ServerConnection& conn, const MutableBuffer& buffer) {
/// need help here
std::cout << "On payload: " << buffer.size() << endl;
};
conn->response().add("Content-Length", "0");
conn->response().add("Connection", "close"); // "keep-alive"
conn->sendHeader();
};
I get this
0:inferImage returnFaceAttributes:true On payload: 65252 On payload: 65536 On payload: 65536 On payload: 34268
I wanted to know if there is an inbuilt multipart-file data parser for ServerConnection. I want my server to handle image uploads. Basically, some class that will automatically combine all the parts and return the buffer which i will then pass on to my image decoder. @auscaster Do I need to do this on my own? or is there a class for this.
Thanks.
Please use the FormWriter
class for this: https://github.com/sourcey/libsourcey/blob/master/src/http/src/form.cpp#L38
I am trying to write a simple http server with libsourcey but I have failed so far.
This code compiles and runs but the server at 1337 doesn't respond!
This is the wrk output
localhost:1337 is available, but is sending nothing in return. Please help. I would also like to know how I can implement routing and stuff.