| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // Simple webserver that returns empty content with the requested mimetype. | 5 // Simple webserver that returns empty content with the requested mimetype. |
| 6 // | 6 // |
| 7 // For example: | 7 // For example: |
| 8 // http://localhost:8080/pepper-application/x-chromoting-plugin | 8 // http://localhost:8080/pepper-application/x-chromoting-plugin |
| 9 // Will return empty content, but with the requested mimetype: | 9 // Will return empty content, but with the requested mimetype: |
| 10 // Content-Type: pepper-application/x-chromoting-plugin | 10 // Content-Type: pepper-application/x-chromoting-plugin |
| 11 // | 11 // |
| 12 // This is useful for testing the Chromoting plugin while we wait for | 12 // This is useful for testing the Chromoting plugin while we wait for |
| 13 // updated mimetype support to be added to Chrome. | 13 // updated mimetype support to be added to Chrome. |
| 14 | 14 |
| 15 #include <stdio.h> | 15 #include <stdio.h> |
| 16 #include <stdlib.h> | 16 #include <stdlib.h> |
| 17 #include <string.h> | 17 #include <string.h> |
| 18 #include <sys/wait.h> | 18 #include <sys/wait.h> |
| 19 #include <netinet/in.h> | 19 #include <netinet/in.h> |
| 20 #include <unistd.h> |
| 20 | 21 |
| 21 #define PORT 8080 | 22 #define PORT 8080 |
| 22 | 23 |
| 23 void error(const char *msg) { | 24 void error(const char *msg) { |
| 24 fprintf(stderr, "ERROR - %s\n", msg); | 25 fprintf(stderr, "ERROR - %s\n", msg); |
| 25 exit(1); | 26 exit(1); |
| 26 } | 27 } |
| 27 | 28 |
| 28 // Read text data from a socket to a buffer. | 29 // Read text data from a socket to a buffer. |
| 29 // Data up to the next \n char is read into the buffer. | 30 // Data up to the next \n char is read into the buffer. |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 } else { | 156 } else { |
| 156 // Parent process. | 157 // Parent process. |
| 157 if (close(connection) < 0) { | 158 if (close(connection) < 0) { |
| 158 error("Unable to close connection in parent"); | 159 error("Unable to close connection in parent"); |
| 159 } | 160 } |
| 160 } | 161 } |
| 161 } | 162 } |
| 162 | 163 |
| 163 return 0; | 164 return 0; |
| 164 } | 165 } |
| OLD | NEW |