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 |
11 #include "SkCommandLineFlags.h" | 11 #include "SkCommandLineFlags.h" |
| 12 #include "SkGraphics.h" |
12 | 13 |
13 #include "microhttpd.h" | 14 #include "microhttpd.h" |
14 | 15 |
15 #include "urlhandlers/UrlHandler.h" | 16 #include "urlhandlers/UrlHandler.h" |
16 | 17 |
17 #include <errno.h> | 18 #include <errno.h> |
18 #include <sys/socket.h> | 19 #include <sys/socket.h> |
19 #include <arpa/inet.h> | 20 #include <arpa/inet.h> |
20 | 21 |
21 using namespace Response; | 22 using namespace Response; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 Request* request = reinterpret_cast<Request*>(cls); | 73 Request* request = reinterpret_cast<Request*>(cls); |
73 int result = kUrlManager.invoke(request, connection, url, method, upload_dat
a, | 74 int result = kUrlManager.invoke(request, connection, url, method, upload_dat
a, |
74 upload_data_size); | 75 upload_data_size); |
75 if (MHD_NO == result) { | 76 if (MHD_NO == result) { |
76 fprintf(stderr, "Invalid method and / or url: %s %s\n", method, url); | 77 fprintf(stderr, "Invalid method and / or url: %s %s\n", method, url); |
77 } | 78 } |
78 return result; | 79 return result; |
79 } | 80 } |
80 | 81 |
81 int skiaserve_main() { | 82 int skiaserve_main() { |
| 83 SkGraphics::Init(); |
82 Request request(SkString("/data")); // This simple server has one request | 84 Request request(SkString("/data")); // This simple server has one request |
83 | 85 |
84 struct sockaddr_in address; | 86 struct sockaddr_in address; |
85 address.sin_family = AF_INET; | 87 address.sin_family = AF_INET; |
86 address.sin_port = htons(FLAGS_port); | 88 address.sin_port = htons(FLAGS_port); |
87 int result = inet_pton(AF_INET, FLAGS_address[0], &address.sin_addr); | 89 int result = inet_pton(AF_INET, FLAGS_address[0], &address.sin_addr); |
88 if (result != 1) { | 90 if (result != 1) { |
89 printf("inet_pton for %s:%d failed with return %d %s\n", | 91 printf("inet_pton for %s:%d failed with return %d %s\n", |
90 FLAGS_address[0], FLAGS_port, result, strerror(errno)); | 92 FLAGS_address[0], FLAGS_port, result, strerror(errno)); |
91 return 1; | 93 return 1; |
(...skipping 19 matching lines...) Expand all Loading... |
111 MHD_stop_daemon(daemon); | 113 MHD_stop_daemon(daemon); |
112 return 0; | 114 return 0; |
113 } | 115 } |
114 | 116 |
115 #if !defined SK_BUILD_FOR_IOS | 117 #if !defined SK_BUILD_FOR_IOS |
116 int main(int argc, char** argv) { | 118 int main(int argc, char** argv) { |
117 SkCommandLineFlags::Parse(argc, argv); | 119 SkCommandLineFlags::Parse(argc, argv); |
118 return skiaserve_main(); | 120 return skiaserve_main(); |
119 } | 121 } |
120 #endif | 122 #endif |
OLD | NEW |