|
3 | 3 | //
|
4 | 4 |
|
5 | 5 | #include <sstream>
|
| 6 | +#include <v8_inspector/third_party/inspector_protocol/crdtp/json.h> |
6 | 7 | #include "NetworkDomainCallbackHandlers.h"
|
7 | 8 | #include "NativeScriptAssert.h"
|
8 | 9 |
|
@@ -65,16 +66,17 @@ void NetworkDomainCallbackHandlers::ResponseReceivedCallback(const v8::FunctionC
|
65 | 66 | throw NativeScriptException("`response` parameter not in the correct format.");
|
66 | 67 | }
|
67 | 68 |
|
68 |
| - auto responseJsonString = ArgConverter::ConvertToUtf16String(responseJson); |
69 |
| - auto responseUtf16Data = responseJsonString.data(); |
70 |
| - auto protocolResponseJson = protocol::StringUtil::parseJSON(String16((const uint16_t*) responseUtf16Data)); |
| 69 | + const String16 responseJsonString = toProtocolString(isolate, responseJson); |
| 70 | + std::vector<uint8_t> cbor; |
| 71 | + v8_crdtp::json::ConvertJSONToCBOR(v8_crdtp::span<uint16_t>(responseJsonString.characters16(), responseJsonString.length()), &cbor); |
| 72 | + std::unique_ptr<protocol::Value> protocolResponseJson = protocol::Value::parseBinary(cbor.data(), cbor.size()); |
71 | 73 |
|
72 | 74 | protocol::ErrorSupport errorSupport;
|
| 75 | + auto protocolResponseObj = protocol::Network::Response::fromValue(protocolResponseJson.get(), &errorSupport); |
73 | 76 |
|
74 |
| - auto protocolResponseObj = protocol::Network::Response::fromValue(protocolResponseJson.get(), |
75 |
| - &errorSupport); |
76 |
| - |
77 |
| - auto errorString = errorSupport.errors().utf8(); |
| 77 | + std::vector<uint8_t> json; |
| 78 | + v8_crdtp::json::ConvertCBORToJSON(errorSupport.Errors(), &json); |
| 79 | + auto errorString = String16(reinterpret_cast<const char*>(json.data()), json.size()).utf8(); |
78 | 80 |
|
79 | 81 | if (!errorString.empty()) {
|
80 | 82 | auto errorMessage = "Error while parsing debug `response` object. ";
|
@@ -166,16 +168,18 @@ void NetworkDomainCallbackHandlers::RequestWillBeSentCallback(const v8::Function
|
166 | 168 | throw NativeScriptException("`request` parameter not in the correct format.");
|
167 | 169 | }
|
168 | 170 |
|
169 |
| - auto requestJsonString = ArgConverter::ConvertToUtf16String(requestJson); |
170 |
| - auto requestUtf16Data = requestJsonString.data(); |
171 |
| - auto protocolRequestJson = protocol::StringUtil::parseJSON(String16((const uint16_t*) requestUtf16Data)); |
| 171 | + const String16& requestJsonString16 = toProtocolString(isolate, requestJson); |
| 172 | + std::vector<uint8_t> cbor; |
| 173 | + v8_crdtp::json::ConvertJSONToCBOR(v8_crdtp::span<uint16_t>(requestJsonString16.characters16(), requestJsonString16.length()), &cbor); |
| 174 | + std::unique_ptr<protocol::Value> protocolRequestJson = protocol::Value::parseBinary(cbor.data(), cbor.size()); |
172 | 175 |
|
173 | 176 | protocol::ErrorSupport errorSupport;
|
174 |
| - |
175 | 177 | auto protocolRequestObj = protocol::Network::Request::fromValue(protocolRequestJson.get(), &errorSupport);
|
176 | 178 | auto initiator = protocol::Network::Initiator::create().setType(protocol::Network::Initiator::TypeEnum::Script).build();
|
177 | 179 |
|
178 |
| - auto errorString = errorSupport.errors().utf8(); |
| 180 | + std::vector<uint8_t> json; |
| 181 | + v8_crdtp::json::ConvertCBORToJSON(errorSupport.Errors(), &json); |
| 182 | + auto errorString = String16(reinterpret_cast<const char*>(json.data()), json.size()).utf8(); |
179 | 183 |
|
180 | 184 | if (!errorString.empty()) {
|
181 | 185 | auto errorMessage = "Error while parsing debug `request` object. ";
|
|
0 commit comments