pikelang / Pike

Pike is a dynamic programming language with a syntax similar to Java and C. It is simple to learn, does not require long compilation passes and has powerful built-in data types allowing simple and really fast data manipulation.
http://pike.lysator.liu.se/
Other
194 stars 34 forks source link

An issue I've encountered when using the async http API #30

Closed TheOnlyArtz closed 5 years ago

TheOnlyArtz commented 5 years ago

Hey, I've tried asking yesterday by mail but still didn't get an answer, I hope you won't be mad I'm asking here, so, 5 months have passed and I've finally managed to send an async request the way I wanted to, and, get a response, now, my issue with this is that the request is being resolved and its data have to be sent to a separate callback which seems like it's impossible to have a function like:

mixed doRequest(<someParams>) {
  mixed mySession = Protocols.HTTP.Session();
  mixed theRequest = HTTPSession->async_post_url(<uri>. <data>, headers_cb, data_cb, fail_cb);
}
void headers_cb(mixed request) {
  write("%O", request->headers()); 
}

void data_cb(mixed data) {
  write("%O", data);
}

void fail_cb(mixed data) {}

Let's say someone wants to call doRequest, how will the method return the data being resolved and set to one of the callbacks (data_cb, headers_cb, fail_cb)?

~Amit aka TheOnlyArtz. I've encountered this issue while working on Fisher

agehall commented 5 years ago

This is something you will have to code yourself. It is not an issue for core pike nor is it a bug of any kind. How you do this is entirely up to your API-design.

Again, please use the appropriate mailing lists to ask questions.