private Multimap<String, String> createHeaders() throws IOException { if (!isValidOptionalField(SceneSerializationConstant.SCENE_TAG_HTTPHEADERS)) { return null; } skipStartObject(); // HTTPHEADERS Multimap<String, String> headers = LinkedHashMultimap.create(); while (_jsonParser.nextToken() != JsonToken.END_OBJECT) { //FIELD_NAME String key = _jsonParser.getCurrentName(); _jsonParser.nextToken(); // VALUE_STRING String value = _jsonParser.getValueAsString(); headers.put(key, value); } if (SceneSerializationConstant.SCENE_TAG_HTTPHEADERS.equals(_jsonParser.getCurrentName()) && _jsonParser.getCurrentToken() == JsonToken.END_OBJECT) { skipEndObject(); } return headers; }
private RecordedHttpExchange createHttpExchange() throws IOException { _jsonParser.nextToken(); // UPDATETIME FIELD_NAME validateRequiredField(SceneSerializationConstant.SCENE_TAG_UPDATE_TIME); _jsonParser.nextToken(); // UPDATETIME VALUE_STRING Date date = new Date(_jsonParser.getValueAsString()); RecordedHttpRequest recordedHttpRequest = createHttpRequest(); RecordedHttpResponse recordedHttpResponse = createHttpResponse(); skipEndObject(); // HTTPEXCHANGE return new RecordedHttpExchange(recordedHttpRequest, recordedHttpResponse, date); }
private List<RecordedHttpExchange> createHttpExchangeList() throws IOException { _jsonParser.nextToken(); //HTTPEXCHANGELIST FIELD_NAME validateRequiredField(SceneSerializationConstant.SCENE_TAG_HTTPEXCHANGE_LIST); skipStartObject(); // HTTPEXCHANGELIST START_OBJECT List<RecordedHttpExchange> recordedHttpExchangeList = new ArrayList<>(); int count = 1; _jsonParser.nextToken(); // HTTPEXCHANGE FIELD_NAME while (_jsonParser.getCurrentToken() != JsonToken.END_OBJECT) { if ((SceneSerializationConstant.SCENE_TAG_HTTPEXCHANGE + count).equals(_jsonParser.getCurrentName())) { skipStartObject(); recordedHttpExchangeList.add(createHttpExchange()); count++; skipEndObject(); // JsonToken.START_OBJECT } } return recordedHttpExchangeList; }
private RecordedHttpBody createHttpBody() throws IOException { if (isValidOptionalField(SceneSerializationConstant.SCENE_TAG_ENCODED_HTTPBODY)) { skipStartObject(); // ENCODEDHTTPBODY _jsonParser.nextToken(); // HTTPBODYENCODING Field validateRequiredField(SceneSerializationConstant.SCENE_TAG_HTTPBODY_ENCODING); _jsonParser.nextToken(); // HTTPBODYENCODING Value String encodingName = _jsonParser.getValueAsString(); _jsonParser.nextToken(); RecordedHttpBody decodedBody = createHttpBody(); // Read in the "decoded" body content so that we can wrap it skipEndObject(); return new RecordedEncodedHttpBody(decodedBody, encodingName); } if (isValidOptionalField(SceneSerializationConstant.SCENE_TAG_STRING_HTTPBODY)) { _jsonParser.nextToken(); // Field return new RecordedStringHttpBody(_jsonParser.getValueAsString()); } if (isValidOptionalField(SceneSerializationConstant.SCENE_TAG_BINARY_HTTPBODY)) { _jsonParser.nextToken(); // Field return new RecordedByteHttpBody(_jsonParser.getBinaryValue()); } return null; }