| 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 size_t count = FDUtils::AvailableBytes(socket); | 160 intptr_t len = Socket::Read(socket, buffer, BUFSIZE); |
| 161 if (count > BUFSIZE) { | |
| 162 count = BUFSIZE; | |
| 163 } | |
| 164 intptr_t len = FDUtils::ReadFromBlocking(socket, buffer, count); | |
| 165 if (len <= 0) { | 161 if (len <= 0) { |
| 166 // Invalid HTTP request, ignore. | 162 // Invalid HTTP request, ignore. |
| 167 continue; | 163 continue; |
| 168 } | 164 } |
| 169 buffer[len] = '\0'; | 165 buffer[len] = '\0'; |
| 170 | 166 |
| 171 // Verify it's a GET request. | 167 // Verify it's a GET request. |
| 172 // TODO(tball): support POST requests. | 168 // TODO(tball): support POST requests. |
| 173 if (strncmp("GET ", buffer, 4) != 0 && strncmp("get ", buffer, 4) != 0) { | 169 if (strncmp("GET ", buffer, 4) != 0 && strncmp("get ", buffer, 4) != 0) { |
| 174 Log::PrintErr("Unsupported HTTP request type"); | 170 Log::PrintErr("Unsupported HTTP request type"); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 VmStatusPlugin* plugin = instance_->registered_plugin_list_; | 323 VmStatusPlugin* plugin = instance_->registered_plugin_list_; |
| 328 while (plugin != NULL) { | 324 while (plugin != NULL) { |
| 329 char* result = (plugin->callback())(request); | 325 char* result = (plugin->callback())(request); |
| 330 if (result != NULL) { | 326 if (result != NULL) { |
| 331 return result; | 327 return result; |
| 332 } | 328 } |
| 333 plugin = plugin->next(); | 329 plugin = plugin->next(); |
| 334 } | 330 } |
| 335 return NULL; | 331 return NULL; |
| 336 } | 332 } |
| OLD | NEW |