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

status codes #67

Open
thurber opened this issue Jan 11, 2017 · 2 comments
Open

status codes #67

thurber opened this issue Jan 11, 2017 · 2 comments
Assignees
Milestone

Comments

@thurber
Copy link

thurber commented Jan 11, 2017

Thanks for the great library; I'm enjoying tinkering with my WICED!

It would be neat if the AdafruitHTTPServer object was able to set the status code of the response within a dynamic callback handler in addition to (or instead of) generating the content. For instance in the example file_not_found_generator, one might hope to do something like the following:

...
void file_not_found_generator (const char* url, const char* query, httppage_request_t* http_request)
{
  (void) url;
  (void) query;
  (void) http_request;
  httpserver.sendStatus(HTTP_STATUS_NOT_FOUND);
}
...

Alternatively, one might desire access to some type of httppage_response_t that could be manipulated in more advanced ways.

@hathach
Copy link
Member

hathach commented Jan 12, 2017

Thanks for posting the suggestion. It is kind of hard to provide a complete solution for the HTTP. Indeed for advanced pages, user may want to pack additional data into the HTTP header. Currently a simple header is written with status = 200 before the generator is invoked. So that normal user only need to focus on the contents, which work for 90% of cases.

For advanced control, maybe we will create another type of HTTPPage where the generator is responsible for sending the header as well (hence everything return to client). There is a bit learning curve for what to include in the header, but this way we will solve this type of request once and for all.

How does it sound ?? If you are not familiar HTTP Response Header, we will add some helper as well ( You've better be though).

PS: We are busy on a new exciting product. Please give us a bit of time, we will get you update when it is done.

@hathach hathach added this to the 0.6.5 milestone Jan 12, 2017
@hathach hathach self-assigned this Jan 12, 2017
@thurber
Copy link
Author

thurber commented Jan 12, 2017

That makes a lot of sense to me. I'm pretty familiar with the headers so that won't be a problem. Thanks, and excited to learn about your new product!

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