| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "Request.h" | 8 #include "Request.h" |
| 9 #include "Response.h" | 9 #include "Response.h" |
| 10 | 10 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 Request request(SkString("/data")); // This simple server has one request | 80 Request request(SkString("/data")); // This simple server has one request |
| 81 | 81 |
| 82 struct sockaddr_in address; | 82 struct sockaddr_in address; |
| 83 address.sin_family = AF_INET; | 83 address.sin_family = AF_INET; |
| 84 address.sin_port = htons(FLAGS_port); | 84 address.sin_port = htons(FLAGS_port); |
| 85 inet_pton(AF_INET, FLAGS_address[0], &address.sin_addr); | 85 inet_pton(AF_INET, FLAGS_address[0], &address.sin_addr); |
| 86 | 86 |
| 87 printf("Visit http://%s:%d in your browser.\n", FLAGS_address[0], FLAGS_port
); | 87 printf("Visit http://%s:%d in your browser.\n", FLAGS_address[0], FLAGS_port
); |
| 88 | 88 |
| 89 struct MHD_Daemon* daemon; | 89 struct MHD_Daemon* daemon; |
| 90 // TODO Add option to bind this strictly to an address, e.g. localhost, for
security. | 90 daemon = MHD_start_daemon(MHD_USE_SELECT_INTERNALLY |
| 91 daemon = MHD_start_daemon(MHD_USE_SELECT_INTERNALLY, FLAGS_port, nullptr, nu
llptr, | 91 #ifdef SK_DEBUG |
| 92 | MHD_USE_DEBUG |
| 93 #endif |
| 94 , FLAGS_port, nullptr, nullptr, |
| 92 &answer_to_connection, &request, | 95 &answer_to_connection, &request, |
| 93 MHD_OPTION_SOCK_ADDR, &address, | 96 MHD_OPTION_SOCK_ADDR, &address, |
| 94 MHD_OPTION_END); | 97 MHD_OPTION_END); |
| 95 if (NULL == daemon) { | 98 if (NULL == daemon) { |
| 99 SkDebugf("Could not initialize daemon\n"); |
| 96 return 1; | 100 return 1; |
| 97 } | 101 } |
| 98 | 102 |
| 99 getchar(); | 103 getchar(); |
| 100 MHD_stop_daemon(daemon); | 104 MHD_stop_daemon(daemon); |
| 101 return 0; | 105 return 0; |
| 102 } | 106 } |
| 103 | 107 |
| 104 #if !defined SK_BUILD_FOR_IOS | 108 #if !defined SK_BUILD_FOR_IOS |
| 105 int main(int argc, char** argv) { | 109 int main(int argc, char** argv) { |
| 106 SkCommandLineFlags::Parse(argc, argv); | 110 SkCommandLineFlags::Parse(argc, argv); |
| 107 return skiaserve_main(); | 111 return skiaserve_main(); |
| 108 } | 112 } |
| 109 #endif | 113 #endif |
| OLD | NEW |