OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stdio.h> | 5 #include <stdio.h> |
6 | 6 |
7 #include "mojo/public/c/system/main.h" | 7 #include "mojo/public/c/system/main.h" |
8 #include "mojo/public/cpp/application/application_delegate.h" | 8 #include "mojo/public/cpp/application/application_delegate.h" |
9 #include "mojo/public/cpp/application/application_impl.h" | 9 #include "mojo/public/cpp/application/application_impl.h" |
10 #include "mojo/public/cpp/application/application_runner.h" | 10 #include "mojo/public/cpp/application/application_runner.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 } | 28 } |
29 | 29 |
30 RunLoop::current()->Quit(); // All done! | 30 RunLoop::current()->Quit(); // All done! |
31 } | 31 } |
32 | 32 |
33 void PrintResponse(const URLResponsePtr& response) const { | 33 void PrintResponse(const URLResponsePtr& response) const { |
34 printf(">>> Headers <<< \n"); | 34 printf(">>> Headers <<< \n"); |
35 printf(" %s\n", response->status_line.get().c_str()); | 35 printf(" %s\n", response->status_line.get().c_str()); |
36 if (response->headers) { | 36 if (response->headers) { |
37 for (size_t i = 0; i < response->headers.size(); ++i) | 37 for (size_t i = 0; i < response->headers.size(); ++i) |
38 printf(" %s\n", response->headers[i].get().c_str()); | 38 printf(" %s=%s\n", |
| 39 response->headers[i]->name.To<std::string>().c_str(), |
| 40 response->headers[i]->value.To<std::string>().c_str()); |
39 } | 41 } |
40 } | 42 } |
41 | 43 |
42 void PrintResponseBody(ScopedDataPipeConsumerHandle body) const { | 44 void PrintResponseBody(ScopedDataPipeConsumerHandle body) const { |
43 // Read response body in blocking fashion. | 45 // Read response body in blocking fashion. |
44 printf(">>> Body <<<\n"); | 46 printf(">>> Body <<<\n"); |
45 | 47 |
46 for (;;) { | 48 for (;;) { |
47 char buf[512]; | 49 char buf[512]; |
48 uint32_t num_bytes = sizeof(buf); | 50 uint32_t num_bytes = sizeof(buf); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 URLLoaderPtr url_loader_; | 105 URLLoaderPtr url_loader_; |
104 }; | 106 }; |
105 | 107 |
106 } // namespace examples | 108 } // namespace examples |
107 } // namespace mojo | 109 } // namespace mojo |
108 | 110 |
109 MojoResult MojoMain(MojoHandle application_request) { | 111 MojoResult MojoMain(MojoHandle application_request) { |
110 mojo::ApplicationRunner runner(new mojo::examples::WGetApp); | 112 mojo::ApplicationRunner runner(new mojo::examples::WGetApp); |
111 return runner.Run(application_request); | 113 return runner.Run(application_request); |
112 } | 114 } |
OLD | NEW |