equal
deleted
inserted
replaced
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 package org.chromium.sdk.internal.transport; |
5 package org.chromium.sdk.internal.transport; |
6 |
6 |
7 import java.io.BufferedReader; |
|
8 import java.io.IOException; |
7 import java.io.IOException; |
9 import java.io.StringWriter; |
8 import java.io.StringWriter; |
10 import java.io.Writer; |
9 import java.io.Writer; |
11 import java.util.HashMap; |
10 import java.util.HashMap; |
12 import java.util.Map; |
11 import java.util.Map; |
13 import java.util.logging.Level; |
12 import java.util.logging.Level; |
14 import java.util.logging.Logger; |
13 import java.util.logging.Logger; |
|
14 |
|
15 import org.chromium.sdk.LineReader; |
15 |
16 |
16 /** |
17 /** |
17 * A transport message encapsulating the data sent/received over the wire |
18 * A transport message encapsulating the data sent/received over the wire |
18 * (protocol headers and content). This class can serialize and deserialize |
19 * (protocol headers and content). This class can serialize and deserialize |
19 * itself into a BufferedWriter according to the ChromeDevTools Protocol |
20 * itself into a BufferedWriter according to the ChromeDevTools Protocol |
111 * or bad message format) |
112 * or bad message format) |
112 * @throws IOException |
113 * @throws IOException |
113 * @throws MalformedMessageException if the input does not represent a valid |
114 * @throws MalformedMessageException if the input does not represent a valid |
114 * message |
115 * message |
115 */ |
116 */ |
116 public static Message fromBufferedReader(BufferedReader reader) |
117 public static Message fromBufferedReader(LineReader reader) |
117 throws IOException, MalformedMessageException { |
118 throws IOException, MalformedMessageException { |
118 Map<String, String> headers = new HashMap<String, String>(); |
119 Map<String, String> headers = new HashMap<String, String>(); |
119 synchronized (reader) { |
120 synchronized (reader) { |
120 while (true) { // read headers |
121 while (true) { // read headers |
121 String line = reader.readLine(); |
122 String line = reader.readLine(); |