Tabnine Logo
MalformedInputException
Code IndexAdd Tabnine to your IDE (free)

How to use
MalformedInputException
in
ro.polak.http.protocol.parser

Best Java code snippets using ro.polak.http.protocol.parser.MalformedInputException (Showing top 8 results out of 315)

origin: piotrpolak/android-http-server

  private Range getRange(final String[] values) throws MalformedInputException {
    try {
      return new Range(Long.parseLong(values[0].trim()), Long.parseLong(values[1].trim()));
    } catch (NumberFormatException e) {
      throw new MalformedInputException("Invalid range value, unable to parse numeric values " + e.getMessage());
    }
  }
}
origin: piotrpolak/android-http-server

  status = statusParser.parse(getStatusLine(in));
} catch (MalformedInputException e) {
  throw new MalformedStatusLineException("Malformed status line " + e.getMessage());
origin: piotrpolak/android-http-server

/**
 * {@inheritDoc}
 */
@Override
public List<Range> parse(final String input) throws MalformedInputException {
  List<Range> rangeList = new ArrayList<>();
  String inputNormalized = input.toLowerCase().trim();
  if (!inputNormalized.startsWith(START_WORD)) {
    throw new MalformedInputException("Header value must start with bytes=");
  }
  String[] rangesString = inputNormalized.substring(START_WORD.length()).split(RANGES_SEPARATOR);
  for (String rangeString : rangesString) {
    if (rangeString.indexOf(RANGE_SEPARATOR) == -1) {
      throw new MalformedInputException("Invalid range value " + rangeString);
    }
    String[] values = rangeString.split(RANGE_SEPARATOR);
    if (values.length != 2) {
      throw new MalformedInputException("Invalid range value " + rangeString);
    }
    rangeList.add(getRange(values));
  }
  return rangeList;
}
origin: piotrpolak/android-http-server

int quotationMarkPosition = name.indexOf("\"");
if (quotationMarkPosition == -1) {
  throw new MalformedInputException("Malformed header, unable to detect value beginning");
} else {
  name = name.substring(0, quotationMarkPosition);
  throw new MalformedInputException("Malformed header, unable to detect value end");
} else {
  fileName = fileName.substring(0, quotationMark2Position);
origin: piotrpolak/android-http-server

throw new MalformedInputException("Input status string should be composed out of "
    + NUMBER_OF_CHUNKS + " chunks. Received " + input);
origin: piotrpolak/android-http-server

@Test(expected = ProtocolException.class)
public void shouldThrowProtocolExceptionOnMalformedHeaders() throws Exception {
  when(headersParser.parse(any(String.class))).thenThrow(new MalformedInputException("ANY"));
  factory.createFromSocket(socket);
}
origin: piotrpolak/android-http-server

@Test
public void shouldAssignNoCookieOnMalformedCookieString() throws Exception {
  headers.setHeader(Headers.HEADER_COOKIE, "ANYTHING");
  when(cookieParser.parse(any(String.class))).thenThrow(new MalformedInputException("ANY"));
  HttpServletRequestImpl request = factory.createFromSocket(socket);
  assertThat(request.getCookies().length, is(0));
  verify(cookieParser, times(1)).parse(any(String.class));
}
origin: piotrpolak/android-http-server

private void handlePostRequest(final HttpServletRequestImpl.Builder builder,
                final InputStream in,
                final Headers headers)
    throws IOException, MalformedInputException {
  int postLength;
  if (headers.containsHeader(Headers.HEADER_CONTENT_LENGTH)) {
    try {
      postLength = Integer.parseInt(headers.getHeader(Headers.HEADER_CONTENT_LENGTH));
    } catch (NumberFormatException e) {
      throw new MalformedInputException(e.getMessage());
    }
  } else {
    throw new LengthRequiredException();
  }
  // Only if post length is greater than 0
  // Keep 0 value - makes no sense to parse the data
  if (postLength < 1) {
    return;
  }
  if (postLength > POST_MAX_LENGTH) {
    throw new PayloadTooLargeProtocolException("Payload of " + postLength + "b exceeds the limit of "
        + POST_MAX_LENGTH + "b");
  }
  if (isMultipartRequest(headers)) {
    handlePostMultipartRequest(builder, headers, in, postLength);
  } else {
    handlePostPlainRequest(builder, in, postLength);
  }
}
ro.polak.http.protocol.parserMalformedInputException

Javadoc

Malformed input exception.

Most used methods

  • <init>
  • getMessage

Popular in Java

  • Parsing JSON documents to java classes using gson
  • notifyDataSetChanged (ArrayAdapter)
  • getContentResolver (Context)
  • requestLocationUpdates (LocationManager)
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • Collectors (java.util.stream)
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now