| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "bin/vmstats_impl.h" | 5 #include "bin/vmstats_impl.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 | 8 |
| 9 #include "bin/fdutils.h" | 9 #include "bin/fdutils.h" |
| 10 #include "bin/file.h" | 10 #include "bin/file.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 return; | 150 return; |
| 151 } | 151 } |
| 152 FDUtils::SetBlocking(socket); | 152 FDUtils::SetBlocking(socket); |
| 153 | 153 |
| 154 // TODO(tball): rewrite this to use STL, so as to eliminate the static | 154 // TODO(tball): rewrite this to use STL, so as to eliminate the static |
| 155 // buffer and support resource URLs that are longer than BUFSIZE. | 155 // buffer and support resource URLs that are longer than BUFSIZE. |
| 156 | 156 |
| 157 // Read request. | 157 // Read request. |
| 158 // TODO(tball): support partial reads, possibly needed for POST uploads. | 158 // TODO(tball): support partial reads, possibly needed for POST uploads. |
| 159 char buffer[BUFSIZE + 1]; | 159 char buffer[BUFSIZE + 1]; |
| 160 int len = read(socket, buffer, BUFSIZE); | 160 size_t count = FDUtils::AvailableBytes(socket); |
| 161 if (count > BUFSIZE) { |
| 162 count = BUFSIZE; |
| 163 } |
| 164 intptr_t len = FDUtils::ReadFromBlocking(socket, buffer, count); |
| 161 if (len <= 0) { | 165 if (len <= 0) { |
| 162 // Invalid HTTP request, ignore. | 166 // Invalid HTTP request, ignore. |
| 163 continue; | 167 continue; |
| 164 } | 168 } |
| 165 buffer[len] = '\0'; | 169 buffer[len] = '\0'; |
| 166 | 170 |
| 167 // Verify it's a GET request. | 171 // Verify it's a GET request. |
| 168 // TODO(tball): support POST requests. | 172 // TODO(tball): support POST requests. |
| 169 if (strncmp("GET ", buffer, 4) != 0 && strncmp("get ", buffer, 4) != 0) { | 173 if (strncmp("GET ", buffer, 4) != 0 && strncmp("get ", buffer, 4) != 0) { |
| 170 Log::PrintErr("Unsupported HTTP request type"); | 174 Log::PrintErr("Unsupported HTTP request type"); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 VmStatusPlugin* plugin = instance_->registered_plugin_list_; | 327 VmStatusPlugin* plugin = instance_->registered_plugin_list_; |
| 324 while (plugin != NULL) { | 328 while (plugin != NULL) { |
| 325 char* result = (plugin->callback())(request); | 329 char* result = (plugin->callback())(request); |
| 326 if (result != NULL) { | 330 if (result != NULL) { |
| 327 return result; | 331 return result; |
| 328 } | 332 } |
| 329 plugin = plugin->next(); | 333 plugin = plugin->next(); |
| 330 } | 334 } |
| 331 return NULL; | 335 return NULL; |
| 332 } | 336 } |
| OLD | NEW |