/* * Copyright (C) 2015 Square, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.squareup.okhttp; import java.io.EOFException; import java.io.IOException; import java.util.ArrayList; import java.util.List; import okio.Buffer; import okio.BufferedSource; /** * A test from the Web Platform * URL test suite. Each test is a line of the file {@code urltestdata.txt}; the format is * informally specified by its JavaScript parser {@code urltestparser.js}; with which this class * attempts to be compatible. * *
Each line of the urltestdata.text file specifies a test. Lines look like this:
{@code * * http://example\t.\norg http://example.org/foo/bar s:http h:example.org p:/ * }*/ public final class WebPlatformUrlTestData { String input; String base; String scheme = ""; String username = ""; String password = null; String host = ""; String port = ""; String path = ""; String query = ""; String fragment = ""; public boolean expectParseFailure() { return scheme.isEmpty(); } private void set(String name, String value) { switch (name) { case "s": scheme = value; break; case "u": username = value; break; case "pass": password = value; break; case "h": host = value; break; case "port": port = value; break; case "p": path = value; break; case "q": query = value; break; case "f": fragment = value; break; default: throw new IllegalArgumentException("unexpected attribute: " + value); } } @Override public String toString() { return String.format("Parsing: <%s> against <%s>", input, base); } public static List