Package graphql.parser
Class SafeTokenReader
java.lang.Object
java.io.Reader
graphql.parser.SafeTokenReader
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Readable
This reader will only emit a maximum number of characters from it. This is used to protect us from evil input.
If a graphql system does not have some max HTTP input limit, then this will help protect the system. This is a limit of last resort. Ideally the http input should be limited, but if its not, we have this.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSafeTokenReader
(Reader delegate, int maxCharacters, Consumer<Integer> whenMaxCharactersExceeded) -
Method Summary
Modifier and TypeMethodDescriptionprivate int
checkHowMany
(int read, int howMany) void
close()
void
mark
(int readAheadLimit) boolean
int
read()
int
read
(char @NotNull [] buff) int
read
(char @NotNull [] buff, int off, int len) int
read
(@NotNull CharBuffer target) boolean
ready()
void
reset()
long
skip
(long n)
-
Field Details
-
delegate
-
maxCharacters
private final int maxCharacters -
whenMaxCharactersExceeded
-
count
private int count
-
-
Constructor Details
-
SafeTokenReader
-
-
Method Details
-
checkHowMany
private int checkHowMany(int read, int howMany) -
read
- Specified by:
read
in classReader
- Throws:
IOException
-
read
- Overrides:
read
in classReader
- Throws:
IOException
-
read
- Specified by:
read
in interfaceReadable
- Overrides:
read
in classReader
- Throws:
IOException
-
read
- Overrides:
read
in classReader
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classReader
- Throws:
IOException
-
skip
- Overrides:
skip
in classReader
- Throws:
IOException
-
ready
- Overrides:
ready
in classReader
- Throws:
IOException
-
markSupported
public boolean markSupported()- Overrides:
markSupported
in classReader
-
mark
- Overrides:
mark
in classReader
- Throws:
IOException
-
reset
- Overrides:
reset
in classReader
- Throws:
IOException
-