Update send_result function
FossilOrigin-Name: 070284b06db0c672bf2e0c63a49f80611909cc531ea12d732de346cfbea5abb9
This commit is contained in:
parent
cebd17dad9
commit
67094237a6
4 changed files with 13 additions and 10 deletions
|
@ -157,7 +157,7 @@ void render_base_page(struct base_page* page, struct session* ssn, mastodont_t*
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
render_html("text/html", data, len);
|
||||
send_result(NULL, "text/html", data, len);
|
||||
|
||||
// Cleanup
|
||||
/* cleanup_all: */
|
||||
|
@ -170,11 +170,13 @@ cleanup:
|
|||
free(instance_str);
|
||||
}
|
||||
|
||||
void render_html(char* content_type, char* data, size_t data_len)
|
||||
void send_result(char* status, char* content_type, char* data, size_t data_len)
|
||||
{
|
||||
if (data_len == 0) data_len = strlen(data);
|
||||
printf("Content-type: %s\r\n"
|
||||
printf("Status: %s\r\n"
|
||||
"Content-type: %s\r\n"
|
||||
"Content-Length: %d\r\n\r\n",
|
||||
status ? status : "200 OK",
|
||||
content_type ? content_type : "text/html",
|
||||
data_len + 1);
|
||||
puts(data);
|
||||
|
|
|
@ -50,10 +50,11 @@ void render_base_page(struct base_page* page, struct session* ssn, mastodont_t*
|
|||
/**
|
||||
* Outputs HTML in format for CGI. This can only be called once!
|
||||
*
|
||||
* @param content_type The Content-Type to display, if NULL, assume "text/html"
|
||||
* @param status The full HTTP status. if NULL, then status is "200 OK"
|
||||
* @param content_type The Content-Type to display. if NULL, assume "text/html"
|
||||
* @param data HTML content
|
||||
* @param data_len Length of data.
|
||||
* @param data_len Length of data. If 0, calls strlen(data)
|
||||
*/
|
||||
void render_html(char* content_type, char* data, size_t data_len);
|
||||
void send_result(char* status, char* content_type, char* data, size_t data_len);
|
||||
|
||||
#endif // BASE_PAGE_H
|
||||
|
|
|
@ -273,7 +273,7 @@ void content_notifications_compact(struct session* ssn, mastodont_t* api, char**
|
|||
|
||||
page = tmpl_gen_notifications_embed(&tdata, &len);
|
||||
|
||||
render_html(NULL, page, len);
|
||||
send_result(NULL, NULL, page, len);
|
||||
|
||||
if (notif_html) free(notif_html);
|
||||
if (navigation_box) free(navigation_box);
|
||||
|
@ -282,5 +282,5 @@ void content_notifications_compact(struct session* ssn, mastodont_t* api, char**
|
|||
|
||||
void api_notifications(struct session* ssn, mastodont_t* api, char** data)
|
||||
{
|
||||
render_html("application/json", "{\"status\":0}", 0);
|
||||
send_result(NULL, "application/json", "{\"status\":0}", 0);
|
||||
}
|
||||
|
|
|
@ -674,10 +674,10 @@ void api_status_interact(struct session* ssn, mastodont_t* api, char** data)
|
|||
{
|
||||
if (try_interact_status(ssn, api, ssn->post.id))
|
||||
{
|
||||
render_html("application/json", "{\"status\":\"Success\"}", 0);
|
||||
send_result(NULL, "application/json", "{\"status\":\"Success\"}", 0);
|
||||
}
|
||||
else
|
||||
render_html("application/json", "{\"status\":\"Couldn't load status\"}", 0);
|
||||
send_result(NULL, "application/json", "{\"status\":\"Couldn't load status\"}", 0);
|
||||
}
|
||||
|
||||
void status_view(struct session* ssn, mastodont_t* api, char** data)
|
||||
|
|
Loading…
Reference in a new issue