@earth-app/shovel
Version:
Kotlin Multiplatform Web Scraping Framework
1,305 lines (1,267 loc) • 83.2 kB
JavaScript
(function (factory) {
if (typeof define === 'function' && define.amd)
define(['exports', './kotlin-kotlin-stdlib.js', './ktor-ktor-http.js', './kotlinx-coroutines-core.js', './ktor-ktor-io.js', './kotlinx-io-kotlinx-io-bytestring.js', './kotlinx-io-kotlinx-io-core.js'], factory);
else if (typeof exports === 'object')
factory(module.exports, require('./kotlin-kotlin-stdlib.js'), require('./ktor-ktor-http.js'), require('./kotlinx-coroutines-core.js'), require('./ktor-ktor-io.js'), require('./kotlinx-io-kotlinx-io-bytestring.js'), require('./kotlinx-io-kotlinx-io-core.js'));
else {
if (typeof globalThis['kotlin-kotlin-stdlib'] === 'undefined') {
throw new Error("Error loading module 'ktor-ktor-http-cio'. Its dependency 'kotlin-kotlin-stdlib' was not found. Please, check whether 'kotlin-kotlin-stdlib' is loaded prior to 'ktor-ktor-http-cio'.");
}
if (typeof globalThis['ktor-ktor-http'] === 'undefined') {
throw new Error("Error loading module 'ktor-ktor-http-cio'. Its dependency 'ktor-ktor-http' was not found. Please, check whether 'ktor-ktor-http' is loaded prior to 'ktor-ktor-http-cio'.");
}
if (typeof globalThis['kotlinx-coroutines-core'] === 'undefined') {
throw new Error("Error loading module 'ktor-ktor-http-cio'. Its dependency 'kotlinx-coroutines-core' was not found. Please, check whether 'kotlinx-coroutines-core' is loaded prior to 'ktor-ktor-http-cio'.");
}
if (typeof globalThis['ktor-ktor-io'] === 'undefined') {
throw new Error("Error loading module 'ktor-ktor-http-cio'. Its dependency 'ktor-ktor-io' was not found. Please, check whether 'ktor-ktor-io' is loaded prior to 'ktor-ktor-http-cio'.");
}
if (typeof globalThis['kotlinx-io-kotlinx-io-bytestring'] === 'undefined') {
throw new Error("Error loading module 'ktor-ktor-http-cio'. Its dependency 'kotlinx-io-kotlinx-io-bytestring' was not found. Please, check whether 'kotlinx-io-kotlinx-io-bytestring' is loaded prior to 'ktor-ktor-http-cio'.");
}
if (typeof globalThis['kotlinx-io-kotlinx-io-core'] === 'undefined') {
throw new Error("Error loading module 'ktor-ktor-http-cio'. Its dependency 'kotlinx-io-kotlinx-io-core' was not found. Please, check whether 'kotlinx-io-kotlinx-io-core' is loaded prior to 'ktor-ktor-http-cio'.");
}
globalThis['ktor-ktor-http-cio'] = factory(typeof globalThis['ktor-ktor-http-cio'] === 'undefined' ? {} : globalThis['ktor-ktor-http-cio'], globalThis['kotlin-kotlin-stdlib'], globalThis['ktor-ktor-http'], globalThis['kotlinx-coroutines-core'], globalThis['ktor-ktor-io'], globalThis['kotlinx-io-kotlinx-io-bytestring'], globalThis['kotlinx-io-kotlinx-io-core']);
}
}(function (_, kotlin_kotlin, kotlin_io_ktor_ktor_http, kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core, kotlin_io_ktor_ktor_io, kotlin_org_jetbrains_kotlinx_kotlinx_io_bytestring, kotlin_org_jetbrains_kotlinx_kotlinx_io_core) {
'use strict';
//region block: imports
var imul = Math.imul;
var Long = kotlin_kotlin.$_$.gb;
var VOID = kotlin_kotlin.$_$.h;
var protoOf = kotlin_kotlin.$_$.z7;
var MultiPartData = kotlin_io_ktor_ktor_http.$_$.k;
var CoroutineScope = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.s;
var initMetadataForClass = kotlin_kotlin.$_$.i7;
var CoroutineImpl = kotlin_kotlin.$_$.m6;
var Unit_instance = kotlin_kotlin.$_$.a3;
var THROW_CCE = kotlin_kotlin.$_$.lb;
var SequenceScope = kotlin_kotlin.$_$.l8;
var get_COROUTINE_SUSPENDED = kotlin_kotlin.$_$.w5;
var initMetadataForLambda = kotlin_kotlin.$_$.n7;
var ArrayList_init_$Create$ = kotlin_kotlin.$_$.p;
var sequence = kotlin_kotlin.$_$.q8;
var toString = kotlin_kotlin.$_$.d8;
var IllegalArgumentException_init_$Create$ = kotlin_kotlin.$_$.o1;
var abs = kotlin_kotlin.$_$.e8;
var StringBuilder_init_$Create$ = kotlin_kotlin.$_$.d1;
var DefaultPool = kotlin_io_ktor_ktor_io.$_$.a1;
var fill = kotlin_kotlin.$_$.h4;
var isIntArray = kotlin_kotlin.$_$.r7;
var _Char___init__impl__6a9atx = kotlin_kotlin.$_$.h2;
var endsWith = kotlin_kotlin.$_$.b9;
var charSequenceLength = kotlin_kotlin.$_$.x6;
var charSequenceGet = kotlin_kotlin.$_$.w6;
var Char = kotlin_kotlin.$_$.xa;
var Char__compareTo_impl_ypi4mb = kotlin_kotlin.$_$.i2;
var contains = kotlin_kotlin.$_$.x8;
var charSequenceSubSequence = kotlin_kotlin.$_$.y6;
var Char__toInt_impl_vasixd = kotlin_kotlin.$_$.n2;
var IllegalStateException = kotlin_kotlin.$_$.eb;
var IllegalStateException_init_$Init$ = kotlin_kotlin.$_$.q1;
var captureStack = kotlin_kotlin.$_$.s6;
var readUTF8LineTo = kotlin_io_ktor_ktor_io.$_$.e;
var IllegalStateException_init_$Create$ = kotlin_kotlin.$_$.r1;
var HttpHeaders_getInstance = kotlin_io_ktor_ktor_http.$_$.g;
var initMetadataForCoroutine = kotlin_kotlin.$_$.k7;
var setOf = kotlin_kotlin.$_$.d5;
var Companion_getInstance = kotlin_io_ktor_ktor_io.$_$.m;
var LineEndingMode__plus_impl_ttpz2j = kotlin_io_ktor_ktor_io.$_$.j;
var listOf = kotlin_kotlin.$_$.t4;
var MultiPart_getInstance = kotlin_io_ktor_ktor_http.$_$.d;
var ByteString_init_$Create$ = kotlin_org_jetbrains_kotlinx_kotlinx_io_bytestring.$_$.a;
var IOException_init_$Create$ = kotlin_org_jetbrains_kotlinx_kotlinx_io_core.$_$.c;
var toString_0 = kotlin_kotlin.$_$.qa;
var toByte = kotlin_kotlin.$_$.a8;
var copyOfRange = kotlin_kotlin.$_$.a4;
var produce = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.i;
var startsWith = kotlin_kotlin.$_$.da;
var readUntil = kotlin_io_ktor_ktor_io.$_$.f;
var WriterScope = kotlin_io_ktor_ktor_io.$_$.f1;
var ProducerScope = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.g;
var isInterface = kotlin_kotlin.$_$.s7;
var counted = kotlin_io_ktor_ktor_io.$_$.i1;
var writer = kotlin_io_ktor_ktor_io.$_$.l1;
var readRemaining = kotlin_io_ktor_ktor_io.$_$.d;
var get_remaining = kotlin_io_ktor_ktor_io.$_$.u;
var skipIfFound = kotlin_io_ktor_ktor_io.$_$.g;
var ByteChannel = kotlin_io_ktor_ktor_io.$_$.c1;
var CompletableDeferred = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.n;
var CancellationException_init_$Create$ = kotlin_kotlin.$_$.w;
var close = kotlin_io_ktor_ktor_io.$_$.h1;
var readPacket = kotlin_io_ktor_ktor_io.$_$.c;
var EOFException_init_$Create$ = kotlin_org_jetbrains_kotlinx_kotlinx_io_core.$_$.a;
var copyTo = kotlin_io_ktor_ktor_io.$_$.a;
var toLong = kotlin_kotlin.$_$.b8;
var toByteArray = kotlin_io_ktor_ktor_io.$_$.w;
var ByteString = kotlin_org_jetbrains_kotlinx_kotlinx_io_bytestring.$_$.c;
var LinkedHashMap_init_$Create$ = kotlin_kotlin.$_$.u;
var compareTo = kotlin_kotlin.$_$.z6;
var NoSuchElementException_init_$Create$ = kotlin_kotlin.$_$.y1;
var Collection = kotlin_kotlin.$_$.c3;
var emptyList = kotlin_kotlin.$_$.e4;
var initMetadataForCompanion = kotlin_kotlin.$_$.j7;
var ensureNotNull = kotlin_kotlin.$_$.sb;
var StringBuilder_init_$Create$_0 = kotlin_kotlin.$_$.c1;
var isCharSequence = kotlin_kotlin.$_$.q7;
var getStringHashCode = kotlin_kotlin.$_$.g7;
var CharSequence = kotlin_kotlin.$_$.wa;
var IndexOutOfBoundsException_init_$Create$ = kotlin_kotlin.$_$.v1;
var NoPoolImpl = kotlin_io_ktor_ktor_io.$_$.b1;
var charArray = kotlin_kotlin.$_$.u6;
var NumberFormatException_init_$Create$ = kotlin_kotlin.$_$.z1;
var toString_1 = kotlin_kotlin.$_$.o2;
var charCodeAt = kotlin_kotlin.$_$.v6;
var Companion_getInstance_0 = kotlin_io_ktor_ktor_http.$_$.h;
var numberRangeToNumber = kotlin_kotlin.$_$.v7;
var collectionSizeOrDefault = kotlin_kotlin.$_$.u3;
var ArrayList_init_$Create$_0 = kotlin_kotlin.$_$.o;
var numberToLong = kotlin_kotlin.$_$.x7;
var toLongArray = kotlin_kotlin.$_$.n5;
var Char__plus_impl_qi7pgj = kotlin_kotlin.$_$.l2;
var Char__minus_impl_a2frrh = kotlin_kotlin.$_$.k2;
var toByteArray_0 = kotlin_kotlin.$_$.i5;
var IOException = kotlin_org_jetbrains_kotlinx_kotlinx_io_core.$_$.g;
var IOException_init_$Init$ = kotlin_org_jetbrains_kotlinx_kotlinx_io_core.$_$.b;
var isWhitespace = kotlin_kotlin.$_$.p9;
//endregion
//region block: pre-declaration
initMetadataForClass(CIOMultipartDataBase, 'CIOMultipartDataBase', VOID, VOID, [MultiPartData, CoroutineScope], [0, 1]);
initMetadataForLambda(HeadersData$headersStarts$slambda, CoroutineImpl, VOID, [1]);
initMetadataForClass(HeadersData, 'HeadersData', HeadersData);
initMetadataForClass(HttpHeadersMap, 'HttpHeadersMap');
initMetadataForClass(IntArrayPool$1, VOID, VOID, DefaultPool);
initMetadataForClass(HeadersDataPool$1, VOID, VOID, DefaultPool);
initMetadataForClass(ParserException, 'ParserException', VOID, IllegalStateException);
initMetadataForCoroutine($parseHeadersCOROUTINE$, CoroutineImpl);
initMetadataForClass(MultipartEvent, 'MultipartEvent');
initMetadataForClass(Preamble, 'Preamble', VOID, MultipartEvent);
initMetadataForClass(MultipartPart, 'MultipartPart', VOID, MultipartEvent);
initMetadataForClass(Epilogue, 'Epilogue', VOID, MultipartEvent);
initMetadataForLambda(parseMultipart$slambda$slambda, CoroutineImpl, VOID, [1]);
initMetadataForLambda(parseMultipart$slambda, CoroutineImpl, VOID, [1]);
initMetadataForCoroutine($parsePartHeadersImplCOROUTINE$, CoroutineImpl);
initMetadataForCoroutine($parsePartBodyImplCOROUTINE$, CoroutineImpl);
initMetadataForCoroutine($skipIfFoundReadCountCOROUTINE$, CoroutineImpl);
initMetadataForClass(Node, 'Node');
initMetadataForCompanion(Companion);
initMetadataForClass(AsciiCharTree, 'AsciiCharTree');
initMetadataForClass(SubSequenceImpl, 'SubSequenceImpl', VOID, VOID, [CharSequence]);
initMetadataForClass(CharArrayBuilder, 'CharArrayBuilder', CharArrayBuilder, VOID, [CharSequence]);
initMetadataForClass(CharArrayPool$1, VOID, VOID, NoPoolImpl);
initMetadataForClass(CharArrayPool$2, VOID, VOID, DefaultPool);
initMetadataForClass(UnsupportedMediaTypeExceptionCIO, 'UnsupportedMediaTypeExceptionCIO', VOID, IOException);
initMetadataForClass(MutableRange, 'MutableRange');
//endregion
function CIOMultipartDataBase(coroutineContext, channel, contentType, contentLength, formFieldLimit) {
formFieldLimit = formFieldLimit === VOID ? new Long(65536, 0) : formFieldLimit;
this.n27_1 = coroutineContext;
this.o27_1 = null;
this.p27_1 = parseMultipart(this, channel, contentType, contentLength, formFieldLimit);
}
protoOf(CIOMultipartDataBase).im = function () {
return this.n27_1;
};
function get_IntArrayPool() {
_init_properties_HttpHeadersMap_kt__hwatby();
return IntArrayPool;
}
var IntArrayPool;
function get_HeadersDataPool() {
_init_properties_HttpHeadersMap_kt__hwatby();
return HeadersDataPool;
}
var HeadersDataPool;
function HeadersData$headersStarts$slambda(this$0, resultContinuation) {
this.y27_1 = this$0;
CoroutineImpl.call(this, resultContinuation);
}
protoOf(HeadersData$headersStarts$slambda).e28 = function ($this$sequence, $completion) {
var tmp = this.f28($this$sequence, $completion);
tmp.o8_1 = Unit_instance;
tmp.p8_1 = null;
return tmp.u8();
};
protoOf(HeadersData$headersStarts$slambda).i9 = function (p1, $completion) {
return this.e28(p1 instanceof SequenceScope ? p1 : THROW_CCE(), $completion);
};
protoOf(HeadersData$headersStarts$slambda).u8 = function () {
var suspendResult = this.o8_1;
$sm: do
try {
var tmp = this.m8_1;
switch (tmp) {
case 0:
this.n8_1 = 7;
this.a28_1 = 0;
this.b28_1 = this.y27_1.g28_1.g();
this.m8_1 = 1;
continue $sm;
case 1:
if (!this.b28_1.h()) {
this.m8_1 = 6;
continue $sm;
}
this.c28_1 = this.b28_1.i();
this.d28_1 = 0;
this.m8_1 = 2;
continue $sm;
case 2:
if (!(this.d28_1 < this.c28_1.length)) {
this.m8_1 = 5;
continue $sm;
}
if (!(this.y27_1.h28(this.a28_1 + 0 | 0) === -1)) {
this.m8_1 = 3;
suspendResult = this.z27_1.eg(this.a28_1, this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
} else {
this.m8_1 = 4;
continue $sm;
}
case 3:
this.m8_1 = 4;
continue $sm;
case 4:
this.d28_1 = this.d28_1 + 6 | 0;
this.a28_1 = this.a28_1 + 6 | 0;
this.m8_1 = 2;
continue $sm;
case 5:
this.m8_1 = 1;
continue $sm;
case 6:
return Unit_instance;
case 7:
throw this.p8_1;
}
} catch ($p) {
var e = $p;
if (this.n8_1 === 7) {
throw e;
} else {
this.m8_1 = this.n8_1;
this.p8_1 = e;
}
}
while (true);
};
protoOf(HeadersData$headersStarts$slambda).f28 = function ($this$sequence, completion) {
var i = new HeadersData$headersStarts$slambda(this.y27_1, completion);
i.z27_1 = $this$sequence;
return i;
};
function HeadersData$headersStarts$slambda_0(this$0, resultContinuation) {
var i = new HeadersData$headersStarts$slambda(this$0, resultContinuation);
var l = function ($this$sequence, $completion) {
return i.e28($this$sequence, $completion);
};
l.$arity = 1;
return l;
}
function HeadersData() {
var tmp = this;
// Inline function 'kotlin.collections.mutableListOf' call
tmp.g28_1 = ArrayList_init_$Create$();
}
protoOf(HeadersData).i28 = function () {
return this.g28_1.j();
};
protoOf(HeadersData).j28 = function (subArraysCount) {
// Inline function 'kotlin.repeat' call
var inductionVariable = 0;
if (inductionVariable < subArraysCount)
do {
var index = inductionVariable;
inductionVariable = inductionVariable + 1 | 0;
this.g28_1.e(get_IntArrayPool().b1m());
}
while (inductionVariable < subArraysCount);
};
protoOf(HeadersData).h28 = function (index) {
return this.g28_1.o(index / 768 | 0)[index % 768 | 0];
};
protoOf(HeadersData).k28 = function (index, value) {
this.g28_1.o(index / 768 | 0)[index % 768 | 0] = value;
};
protoOf(HeadersData).l28 = function () {
return sequence(HeadersData$headersStarts$slambda_0(this, null));
};
protoOf(HeadersData).m28 = function () {
var _iterator__ex2g4s = this.g28_1.g();
while (_iterator__ex2g4s.h()) {
var array = _iterator__ex2g4s.i();
get_IntArrayPool().c1m(array);
}
this.g28_1.y1();
};
function thresholdReached($this) {
return $this.o28_1 >= $this.p28_1 * 0.75;
}
function resize($this) {
var prevSize = $this.o28_1;
var prevData = $this.q28_1;
$this.o28_1 = 0;
$this.p28_1 = imul($this.p28_1, 2) | 128;
var tmp = $this;
// Inline function 'kotlin.apply' call
var this_0 = get_HeadersDataPool().b1m();
this_0.j28(imul(prevData.i28(), 2) | 1);
tmp.q28_1 = this_0;
var _iterator__ex2g4s = prevData.l28().g();
while (_iterator__ex2g4s.h()) {
var headerOffset = _iterator__ex2g4s.i();
$this.r28(prevData.h28(headerOffset + 1 | 0), prevData.h28(headerOffset + 2 | 0), prevData.h28(headerOffset + 3 | 0), prevData.h28(headerOffset + 4 | 0));
}
get_HeadersDataPool().c1m(prevData);
// Inline function 'kotlin.require' call
// Inline function 'kotlin.require' call
if (!(prevSize === $this.o28_1)) {
var message = 'Failed requirement.';
throw IllegalArgumentException_init_$Create$(toString(message));
}
}
function headerHasName($this, name, headerOffset) {
var nameStartIndex = $this.q28_1.h28(headerOffset + 1 | 0);
var nameEndIndex = $this.q28_1.h28(headerOffset + 2 | 0);
return equalsLowerCase($this.n28_1, nameStartIndex, nameEndIndex, name);
}
function HttpHeadersMap(builder) {
this.n28_1 = builder;
this.o28_1 = 0;
this.p28_1 = 0;
this.q28_1 = get_HeadersDataPool().b1m();
}
protoOf(HttpHeadersMap).pd = function (name) {
if (this.o28_1 === 0)
return null;
// Inline function 'kotlin.math.absoluteValue' call
var this_0 = hashCodeLowerCase(name);
var hash = abs(this_0);
var headerIndex = hash % this.p28_1 | 0;
while (!(this.q28_1.h28(imul(headerIndex, 6) + 0 | 0) === -1)) {
if (headerHasName(this, name, imul(headerIndex, 6))) {
return this.s28(imul(headerIndex, 6));
}
headerIndex = (headerIndex + 1 | 0) % this.p28_1 | 0;
}
return null;
};
protoOf(HttpHeadersMap).t28 = function () {
return this.q28_1.l28();
};
protoOf(HttpHeadersMap).r28 = function (nameStartIndex, nameEndIndex, valueStartIndex, valueEndIndex) {
if (thresholdReached(this)) {
resize(this);
}
// Inline function 'kotlin.math.absoluteValue' call
var this_0 = hashCodeLowerCase(this.n28_1, nameStartIndex, nameEndIndex);
var hash = abs(this_0);
var name = this.n28_1.c(nameStartIndex, nameEndIndex);
var headerIndex = hash % this.p28_1 | 0;
var sameNameHeaderIndex = -1;
while (!(this.q28_1.h28(imul(headerIndex, 6) + 0 | 0) === -1)) {
if (headerHasName(this, name, imul(headerIndex, 6))) {
sameNameHeaderIndex = headerIndex;
}
headerIndex = (headerIndex + 1 | 0) % this.p28_1 | 0;
}
var headerOffset = imul(headerIndex, 6);
this.q28_1.k28(headerOffset + 0 | 0, hash);
this.q28_1.k28(headerOffset + 1 | 0, nameStartIndex);
this.q28_1.k28(headerOffset + 2 | 0, nameEndIndex);
this.q28_1.k28(headerOffset + 3 | 0, valueStartIndex);
this.q28_1.k28(headerOffset + 4 | 0, valueEndIndex);
this.q28_1.k28(headerOffset + 5 | 0, -1);
if (!(sameNameHeaderIndex === -1)) {
this.q28_1.k28(imul(sameNameHeaderIndex, 6) + 5 | 0, headerIndex);
}
this.o28_1 = this.o28_1 + 1 | 0;
};
protoOf(HttpHeadersMap).b29 = function (headerOffset) {
var nameStartIndex = this.q28_1.h28(headerOffset + 1 | 0);
var nameEndIndex = this.q28_1.h28(headerOffset + 2 | 0);
return this.n28_1.c(nameStartIndex, nameEndIndex);
};
protoOf(HttpHeadersMap).s28 = function (headerOffset) {
var valueStartIndex = this.q28_1.h28(headerOffset + 3 | 0);
var valueEndIndex = this.q28_1.h28(headerOffset + 4 | 0);
return this.n28_1.c(valueStartIndex, valueEndIndex);
};
protoOf(HttpHeadersMap).m28 = function () {
this.o28_1 = 0;
this.p28_1 = 0;
get_HeadersDataPool().c1m(this.q28_1);
this.q28_1 = get_HeadersDataPool().b1m();
};
protoOf(HttpHeadersMap).toString = function () {
// Inline function 'kotlin.text.buildString' call
// Inline function 'kotlin.apply' call
var this_0 = StringBuilder_init_$Create$();
dumpTo(this, '', this_0);
return this_0.toString();
};
function dumpTo(_this__u8e3s4, indent, out) {
_init_properties_HttpHeadersMap_kt__hwatby();
var _iterator__ex2g4s = _this__u8e3s4.t28().g();
while (_iterator__ex2g4s.h()) {
var offset = _iterator__ex2g4s.i();
out.f(indent);
out.f(_this__u8e3s4.b29(offset));
out.f(' => ');
out.f(_this__u8e3s4.s28(offset));
out.f('\n');
}
}
function IntArrayPool$1() {
DefaultPool.call(this, 1000);
}
protoOf(IntArrayPool$1).u1l = function () {
var tmp = 0;
var tmp_0 = new Int32Array(768);
while (tmp < 768) {
tmp_0[tmp] = -1;
tmp = tmp + 1 | 0;
}
return tmp_0;
};
protoOf(IntArrayPool$1).f29 = function (instance) {
fill(instance, -1);
return protoOf(DefaultPool).z1l.call(this, instance);
};
protoOf(IntArrayPool$1).z1l = function (instance) {
return this.f29(isIntArray(instance) ? instance : THROW_CCE());
};
function HeadersDataPool$1() {
DefaultPool.call(this, 1000);
}
protoOf(HeadersDataPool$1).u1l = function () {
return new HeadersData();
};
protoOf(HeadersDataPool$1).j29 = function (instance) {
instance.m28();
return protoOf(DefaultPool).z1l.call(this, instance);
};
protoOf(HeadersDataPool$1).z1l = function (instance) {
return this.j29(instance instanceof HeadersData ? instance : THROW_CCE());
};
var properties_initialized_HttpHeadersMap_kt_kotj4w;
function _init_properties_HttpHeadersMap_kt__hwatby() {
if (!properties_initialized_HttpHeadersMap_kt_kotj4w) {
properties_initialized_HttpHeadersMap_kt_kotj4w = true;
IntArrayPool = new IntArrayPool$1();
HeadersDataPool = new HeadersDataPool$1();
}
}
function get_hostForbiddenSymbols() {
_init_properties_HttpParser_kt__gbdom1();
return hostForbiddenSymbols;
}
var hostForbiddenSymbols;
function get_httpLineEndings() {
_init_properties_HttpParser_kt__gbdom1();
return httpLineEndings;
}
var httpLineEndings;
var versions;
function parseHeaders(input, builder, range, $completion) {
range = range === VOID ? new MutableRange(0, 0) : range;
var tmp = new $parseHeadersCOROUTINE$(input, builder, range, $completion);
tmp.o8_1 = Unit_instance;
tmp.p8_1 = null;
return tmp.u8();
}
function parseHeaderName(text, range) {
_init_properties_HttpParser_kt__gbdom1();
var index = range.w29_1;
var end = range.x29_1;
while (index < end) {
var ch = text.b(index);
if (ch === _Char___init__impl__6a9atx(58) && !(index === range.w29_1)) {
range.w29_1 = index + 1 | 0;
return index;
}
if (isDelimiter(ch)) {
parseHeaderNameFailed(text, index, range.w29_1, ch);
}
index = index + 1 | 0;
}
noColonFound(text, range);
}
function parseHeaderValue(text, range) {
_init_properties_HttpParser_kt__gbdom1();
var start = range.w29_1;
var end = range.x29_1;
var index = start;
index = skipSpacesAndHorizontalTabs(text, index, end);
if (index >= end) {
range.w29_1 = end;
return Unit_instance;
}
var valueStart = index;
var valueLastIndex = index;
while (index < end) {
var ch = text.b(index);
if (ch !== _Char___init__impl__6a9atx(9) && ch !== _Char___init__impl__6a9atx(32))
if (ch === _Char___init__impl__6a9atx(13) || ch === _Char___init__impl__6a9atx(10)) {
characterIsNotAllowed(text, ch);
} else
valueLastIndex = index;
index = index + 1 | 0;
}
range.w29_1 = valueStart;
range.x29_1 = valueLastIndex + 1 | 0;
}
function validateHostHeader(host) {
_init_properties_HttpParser_kt__gbdom1();
if (endsWith(host, ':')) {
throw new ParserException("Host header with ':' should contains port: " + toString(host));
}
var tmp$ret$1;
$l$block: {
// Inline function 'kotlin.text.any' call
var inductionVariable = 0;
while (inductionVariable < charSequenceLength(host)) {
var element = charSequenceGet(host, inductionVariable);
inductionVariable = inductionVariable + 1 | 0;
if (get_hostForbiddenSymbols().p1(new Char(element))) {
tmp$ret$1 = true;
break $l$block;
}
}
tmp$ret$1 = false;
}
if (tmp$ret$1) {
throw new ParserException('Host cannot contain any of the following symbols: ' + toString(get_hostForbiddenSymbols()));
}
}
function isDelimiter(ch) {
_init_properties_HttpParser_kt__gbdom1();
return Char__compareTo_impl_ypi4mb(ch, _Char___init__impl__6a9atx(32)) <= 0 || contains('"(),/:;<=>?@[\\]{}', ch);
}
function parseHeaderNameFailed(text, index, start, ch) {
_init_properties_HttpParser_kt__gbdom1();
if (ch === _Char___init__impl__6a9atx(58)) {
throw new ParserException('Empty header names are not allowed as per RFC7230.');
}
if (index === start) {
throw new ParserException('Multiline headers via line folding is not supported since it is deprecated as per RFC7230.');
}
characterIsNotAllowed(text, ch);
}
function noColonFound(text, range) {
_init_properties_HttpParser_kt__gbdom1();
var tmp2 = range.w29_1;
// Inline function 'kotlin.text.substring' call
var endIndex = range.x29_1;
var tmp$ret$0 = toString(charSequenceSubSequence(text, tmp2, endIndex));
throw new ParserException('No colon in HTTP header in ' + tmp$ret$0 + ' in builder: \n' + toString(text));
}
function characterIsNotAllowed(text, ch) {
_init_properties_HttpParser_kt__gbdom1();
// Inline function 'kotlin.code' call
var tmp$ret$0 = Char__toInt_impl_vasixd(ch);
throw new ParserException('Character with code ' + (tmp$ret$0 & 255) + ' is not allowed in header names, \n' + toString(text));
}
function ParserException(message) {
IllegalStateException_init_$Init$(message, this);
captureStack(this, ParserException);
}
function $parseHeadersCOROUTINE$(input, builder, range, resultContinuation) {
CoroutineImpl.call(this, resultContinuation);
this.s29_1 = input;
this.t29_1 = builder;
this.u29_1 = range;
}
protoOf($parseHeadersCOROUTINE$).u8 = function () {
var suspendResult = this.o8_1;
$sm: do
try {
var tmp = this.m8_1;
switch (tmp) {
case 0:
this.n8_1 = 7;
this.v29_1 = new HttpHeadersMap(this.t29_1);
this.n8_1 = 6;
this.m8_1 = 1;
continue $sm;
case 1:
if (!true) {
this.m8_1 = 5;
continue $sm;
}
this.m8_1 = 2;
suspendResult = readUTF8LineTo(this.s29_1, this.t29_1, 8192, get_httpLineEndings(), this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 2:
var ARGUMENT = suspendResult;
if (!ARGUMENT) {
this.v29_1.m28();
return null;
} else {
this.m8_1 = 3;
continue $sm;
}
case 3:
this.u29_1.x29_1 = this.t29_1.a29_1;
var rangeLength = this.u29_1.x29_1 - this.u29_1.w29_1 | 0;
if (rangeLength === 0) {
this.m8_1 = 5;
continue $sm;
} else {
this.m8_1 = 4;
continue $sm;
}
case 4:
if (rangeLength >= 8192) {
var message = 'Header line length limit exceeded';
throw IllegalStateException_init_$Create$(toString(message));
}
var nameStart = this.u29_1.w29_1;
var nameEnd = parseHeaderName(this.t29_1, this.u29_1);
var headerEnd = this.u29_1.x29_1;
parseHeaderValue(this.t29_1, this.u29_1);
var valueStart = this.u29_1.w29_1;
var valueEnd = this.u29_1.x29_1;
this.u29_1.w29_1 = headerEnd;
this.v29_1.r28(nameStart, nameEnd, valueStart, valueEnd);
this.m8_1 = 1;
continue $sm;
case 5:
var host = this.v29_1.pd(HttpHeaders_getInstance().u1y_1);
if (!(host == null)) {
validateHostHeader(host);
}
return this.v29_1;
case 6:
this.n8_1 = 7;
var tmp_0 = this.p8_1;
if (tmp_0 instanceof Error) {
var t = this.p8_1;
this.v29_1.m28();
throw t;
} else {
throw this.p8_1;
}
case 7:
throw this.p8_1;
}
} catch ($p) {
var e = $p;
if (this.n8_1 === 7) {
throw e;
} else {
this.m8_1 = this.n8_1;
this.p8_1 = e;
}
}
while (true);
};
var properties_initialized_HttpParser_kt_uedryv;
function _init_properties_HttpParser_kt__gbdom1() {
if (!properties_initialized_HttpParser_kt_uedryv) {
properties_initialized_HttpParser_kt_uedryv = true;
hostForbiddenSymbols = setOf([new Char(_Char___init__impl__6a9atx(47)), new Char(_Char___init__impl__6a9atx(63)), new Char(_Char___init__impl__6a9atx(35)), new Char(_Char___init__impl__6a9atx(64))]);
httpLineEndings = LineEndingMode__plus_impl_ttpz2j(Companion_getInstance().v1g_1, Companion_getInstance().u1g_1);
versions = Companion_instance.y29(listOf(['HTTP/1.0', 'HTTP/1.1']));
}
}
function get_CrLf() {
_init_properties_Multipart_kt__ato98a();
return CrLf;
}
var CrLf;
function get_PrefixString() {
_init_properties_Multipart_kt__ato98a();
return PrefixString;
}
var PrefixString;
function Preamble(body) {
MultipartEvent.call(this);
this.z29_1 = body;
}
function MultipartPart(headers, body) {
MultipartEvent.call(this);
this.a2a_1 = headers;
this.b2a_1 = body;
}
function Epilogue(body) {
MultipartEvent.call(this);
this.c2a_1 = body;
}
function MultipartEvent() {
}
function parseMultipart(_this__u8e3s4, input, contentType, contentLength, maxPartSize) {
maxPartSize = maxPartSize === VOID ? new Long(-1, 2147483647) : maxPartSize;
_init_properties_Multipart_kt__ato98a();
if (!MultiPart_getInstance().u1w(contentType)) {
throw new UnsupportedMediaTypeExceptionCIO('Failed to parse multipart: Content-Type should be multipart/* but it is ' + toString(contentType));
}
var boundaryByteBuffer = parseBoundaryInternal(contentType);
var boundaryBytes = ByteString_init_$Create$(boundaryByteBuffer);
return parseMultipart_0(_this__u8e3s4, boundaryBytes, input, contentLength, maxPartSize);
}
function parseBoundaryInternal(contentType) {
_init_properties_Multipart_kt__ato98a();
var boundaryParameter = findBoundary(contentType);
if (boundaryParameter === -1) {
throw IOException_init_$Create$("Failed to parse multipart: Content-Type's boundary parameter is missing");
}
var boundaryStart = boundaryParameter + 9 | 0;
var boundaryBytes = new Int8Array(74);
var position = {_v: 0};
parseBoundaryInternal$put(position, boundaryBytes, 13);
parseBoundaryInternal$put(position, boundaryBytes, 10);
parseBoundaryInternal$put(position, boundaryBytes, 45);
parseBoundaryInternal$put(position, boundaryBytes, 45);
var state = 0;
var inductionVariable = boundaryStart;
var last = charSequenceLength(contentType);
if (inductionVariable < last)
loop: do {
var i = inductionVariable;
inductionVariable = inductionVariable + 1 | 0;
var ch = charSequenceGet(contentType, i);
// Inline function 'kotlin.code' call
var v = Char__toInt_impl_vasixd(ch) & 65535;
if ((v & 65535) > 127) {
throw IOException_init_$Create$('Failed to parse multipart: wrong boundary byte 0x' + toString_0(v, 16) + ' - should be 7bit character');
}
switch (state) {
case 0:
if (ch !== _Char___init__impl__6a9atx(32))
if (ch === _Char___init__impl__6a9atx(34)) {
state = 2;
} else if (ch === _Char___init__impl__6a9atx(59) || ch === _Char___init__impl__6a9atx(44)) {
break loop;
} else {
state = 1;
parseBoundaryInternal$put(position, boundaryBytes, toByte(v));
}
break;
case 1:
if (ch === _Char___init__impl__6a9atx(32) || ch === _Char___init__impl__6a9atx(44) || ch === _Char___init__impl__6a9atx(59)) {
break loop;
} else {
parseBoundaryInternal$put(position, boundaryBytes, toByte(v));
}
break;
case 2:
if (ch === _Char___init__impl__6a9atx(92)) {
state = 3;
} else if (ch === _Char___init__impl__6a9atx(34)) {
break loop;
} else {
parseBoundaryInternal$put(position, boundaryBytes, toByte(v));
}
break;
case 3:
parseBoundaryInternal$put(position, boundaryBytes, toByte(v));
state = 2;
break;
}
}
while (inductionVariable < last);
if (position._v === 4) {
throw IOException_init_$Create$('Empty multipart boundary is not allowed');
}
return copyOfRange(boundaryBytes, 0, position._v);
}
function parseMultipart_0(_this__u8e3s4, boundaryPrefixed, input, totalLength, maxPartSize) {
_init_properties_Multipart_kt__ato98a();
return produce(_this__u8e3s4, VOID, VOID, parseMultipart$slambda_0(input, boundaryPrefixed, maxPartSize, totalLength, null));
}
function findBoundary(contentType) {
_init_properties_Multipart_kt__ato98a();
var state = 0;
var paramNameCount = 0;
var inductionVariable = 0;
var last = charSequenceLength(contentType) - 1 | 0;
if (inductionVariable <= last)
do {
var i = inductionVariable;
inductionVariable = inductionVariable + 1 | 0;
var ch = charSequenceGet(contentType, i);
switch (state) {
case 0:
if (ch === _Char___init__impl__6a9atx(59)) {
state = 1;
paramNameCount = 0;
}
break;
case 1:
if (ch === _Char___init__impl__6a9atx(61)) {
state = 2;
} else if (ch === _Char___init__impl__6a9atx(59)) {
paramNameCount = 0;
} else if (ch === _Char___init__impl__6a9atx(44)) {
state = 0;
} else if (ch !== _Char___init__impl__6a9atx(32))
if (paramNameCount === 0 && startsWith(contentType, 'boundary=', i, true)) {
return i;
} else {
paramNameCount = paramNameCount + 1 | 0;
}
break;
case 2:
if (ch === _Char___init__impl__6a9atx(34))
state = 3;
else if (ch === _Char___init__impl__6a9atx(44))
state = 0;
else if (ch === _Char___init__impl__6a9atx(59)) {
state = 1;
paramNameCount = 0;
}
break;
case 3:
if (ch === _Char___init__impl__6a9atx(34)) {
state = 1;
paramNameCount = 0;
} else if (ch === _Char___init__impl__6a9atx(92)) {
state = 4;
}
break;
case 4:
state = 3;
break;
}
}
while (inductionVariable <= last);
return -1;
}
function parsePreambleImpl(boundary, input, output, limit, $completion) {
limit = limit === VOID ? new Long(-1, 2147483647) : limit;
return readUntil(input, boundary, output, limit, true, $completion);
}
function parsePartHeadersImpl(input, $completion) {
var tmp = new $parsePartHeadersImplCOROUTINE$(input, $completion);
tmp.o8_1 = Unit_instance;
tmp.p8_1 = null;
return tmp.u8();
}
function parsePartBodyImpl(boundaryPrefixed, input, output, headers, limit, $completion) {
var tmp = new $parsePartBodyImplCOROUTINE$(boundaryPrefixed, input, output, headers, limit, $completion);
tmp.o8_1 = Unit_instance;
tmp.p8_1 = null;
return tmp.u8();
}
function skipIfFoundReadCount(_this__u8e3s4, prefix, $completion) {
var tmp = new $skipIfFoundReadCountCOROUTINE$(_this__u8e3s4, prefix, $completion);
tmp.o8_1 = Unit_instance;
tmp.p8_1 = null;
return tmp.u8();
}
function throwLimitExceeded(actual, limit) {
_init_properties_Multipart_kt__ato98a();
throw IOException_init_$Create$('Multipart content length exceeds limit ' + actual.toString() + ' > ' + limit.toString() + '; ' + "limit is defined using 'formFieldLimit' argument");
}
function parseBoundaryInternal$put(position, boundaryBytes, value) {
if (position._v >= boundaryBytes.length) {
throw IOException_init_$Create$("Failed to parse multipart: boundary shouldn't be longer than 70 characters");
}
var _unary__edvuaz = position._v;
position._v = _unary__edvuaz + 1 | 0;
boundaryBytes[_unary__edvuaz] = value;
}
function parseMultipart$slambda$slambda($firstBoundary, $countedInput, resultContinuation) {
this.y2b_1 = $firstBoundary;
this.z2b_1 = $countedInput;
CoroutineImpl.call(this, resultContinuation);
}
protoOf(parseMultipart$slambda$slambda).b2c = function ($this$writer, $completion) {
var tmp = this.c2c($this$writer, $completion);
tmp.o8_1 = Unit_instance;
tmp.p8_1 = null;
return tmp.u8();
};
protoOf(parseMultipart$slambda$slambda).i9 = function (p1, $completion) {
return this.b2c(p1 instanceof WriterScope ? p1 : THROW_CCE(), $completion);
};
protoOf(parseMultipart$slambda$slambda).u8 = function () {
var suspendResult = this.o8_1;
$sm: do
try {
var tmp = this.m8_1;
switch (tmp) {
case 0:
this.n8_1 = 3;
this.m8_1 = 1;
suspendResult = parsePreambleImpl(this.y2b_1, this.z2b_1, this.a2c_1.j1j_1, new Long(8193, 0), this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 1:
this.m8_1 = 2;
suspendResult = this.a2c_1.j1j_1.f1c(this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 2:
return Unit_instance;
case 3:
throw this.p8_1;
}
} catch ($p) {
var e = $p;
if (this.n8_1 === 3) {
throw e;
} else {
this.m8_1 = this.n8_1;
this.p8_1 = e;
}
}
while (true);
};
protoOf(parseMultipart$slambda$slambda).c2c = function ($this$writer, completion) {
var i = new parseMultipart$slambda$slambda(this.y2b_1, this.z2b_1, completion);
i.a2c_1 = $this$writer;
return i;
};
function parseMultipart$slambda$slambda_0($firstBoundary, $countedInput, resultContinuation) {
var i = new parseMultipart$slambda$slambda($firstBoundary, $countedInput, resultContinuation);
var l = function ($this$writer, $completion) {
return i.b2c($this$writer, $completion);
};
l.$arity = 1;
return l;
}
function parseMultipart$slambda($input, $boundaryPrefixed, $maxPartSize, $totalLength, resultContinuation) {
this.l2c_1 = $input;
this.m2c_1 = $boundaryPrefixed;
this.n2c_1 = $maxPartSize;
this.o2c_1 = $totalLength;
CoroutineImpl.call(this, resultContinuation);
}
protoOf(parseMultipart$slambda).g2d = function ($this$produce, $completion) {
var tmp = this.h2d($this$produce, $completion);
tmp.o8_1 = Unit_instance;
tmp.p8_1 = null;
return tmp.u8();
};
protoOf(parseMultipart$slambda).i9 = function (p1, $completion) {
return this.g2d((!(p1 == null) ? isInterface(p1, ProducerScope) : false) ? p1 : THROW_CCE(), $completion);
};
protoOf(parseMultipart$slambda).u8 = function () {
var suspendResult = this.o8_1;
$sm: do
try {
var tmp = this.m8_1;
switch (tmp) {
case 0:
this.n8_1 = 23;
this.q2c_1 = counted(this.l2c_1);
this.r2c_1 = this.q2c_1.i1l();
this.s2c_1 = this.m2c_1.i16(get_PrefixString().j());
this.m8_1 = 1;
suspendResult = readRemaining(writer(this.p2c_1, VOID, VOID, parseMultipart$slambda$slambda_0(this.s2c_1, this.q2c_1, null)).h1j_1, this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 1:
this.t2c_1 = suspendResult;
if (get_remaining(this.t2c_1).a1(new Long(0, 0)) > 0) {
this.m8_1 = 2;
suspendResult = this.p2c_1.h12(new Preamble(this.t2c_1), this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
} else {
this.m8_1 = 3;
continue $sm;
}
case 2:
this.m8_1 = 3;
continue $sm;
case 3:
this.m8_1 = 4;
continue $sm;
case 4:
if (!this.q2c_1.c1c()) {
this.m8_1 = 5;
suspendResult = skipIfFound(this.q2c_1, get_PrefixString(), this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
} else {
this.u2c_1 = false;
this.m8_1 = 6;
continue $sm;
}
case 5:
this.v2c_1 = suspendResult;
this.u2c_1 = !this.v2c_1;
this.m8_1 = 6;
continue $sm;
case 6:
if (!this.u2c_1) {
this.m8_1 = 13;
continue $sm;
}
this.m8_1 = 7;
suspendResult = skipIfFound(this.q2c_1, get_CrLf(), this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 7:
this.w2c_1 = new ByteChannel();
this.x2c_1 = CompletableDeferred();
this.y2c_1 = new MultipartPart(this.x2c_1, this.w2c_1);
this.m8_1 = 8;
suspendResult = this.p2c_1.h12(this.y2c_1, this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 8:
this.z2c_1 = null;
this.n8_1 = 12;
this.m8_1 = 9;
suspendResult = parsePartHeadersImpl(this.q2c_1, this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 9:
this.z2c_1 = suspendResult;
if (!this.x2c_1.ys(this.z2c_1)) {
this.z2c_1.m28();
throw CancellationException_init_$Create$('Multipart processing has been cancelled');
}
this.m8_1 = 10;
suspendResult = parsePartBodyImpl(this.m2c_1, this.q2c_1, this.w2c_1, this.z2c_1, this.n2c_1, this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 10:
this.w2c_1.x3();
this.n8_1 = 23;
this.m8_1 = 11;
continue $sm;
case 11:
this.n8_1 = 23;
this.m8_1 = 4;
continue $sm;
case 12:
this.n8_1 = 23;
var tmp_0 = this.p8_1;
if (tmp_0 instanceof Error) {
this.a2d_1 = this.p8_1;
if (this.x2c_1.at(this.a2d_1)) {
var tmp0_safe_receiver = this.z2c_1;
if (tmp0_safe_receiver == null)
null;
else {
tmp0_safe_receiver.m28();
}
}
close(this.w2c_1, this.a2d_1);
throw this.a2d_1;
} else {
throw this.p8_1;
}
case 13:
this.m8_1 = 14;
suspendResult = skipIfFound(this.q2c_1, get_CrLf(), this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 14:
this.m8_1 = 15;
suspendResult = skipIfFound(this.q2c_1, get_CrLf(), this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 15:
if (!(this.o2c_1 == null)) {
this.b2d_1 = this.q2c_1.i1l().s2(this.r2c_1);
this.c2d_1 = this.o2c_1.s2(this.b2d_1);
if (this.c2d_1.a1(new Long(2147483647, 0)) > 0)
throw IOException_init_$Create$('Failed to parse multipart: prologue is too long');
if (this.c2d_1.a1(new Long(0, 0)) > 0) {
this.m8_1 = 19;
suspendResult = readPacket(this.q2c_1, this.c2d_1.z(), this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
} else {
this.m8_1 = 21;
continue $sm;
}
} else {
this.m8_1 = 16;
suspendResult = readRemaining(this.q2c_1, this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
}
case 16:
this.d2d_1 = suspendResult;
if (!this.d2d_1.q16()) {
this.m8_1 = 17;
suspendResult = this.p2c_1.h12(new Epilogue(this.d2d_1), this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
} else {
this.m8_1 = 18;
continue $sm;
}
case 17:
this.m8_1 = 18;
continue $sm;
case 18:
this.m8_1 = 22;
continue $sm;
case 19:
this.e2d_1 = suspendResult;
this.f2d_1 = new Epilogue(this.e2d_1);
this.m8_1 = 20;
suspendResult = this.p2c_1.h12(this.f2d_1, this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 20:
this.m8_1 = 21;
continue $sm;
case 21:
this.m8_1 = 22;
continue $sm;
case 22:
return Unit_instance;
case 23:
throw this.p8_1;
}
} catch ($p) {
var e = $p;
if (this.n8_1 === 23) {
throw e;
} else {
this.m8_1 = this.n8_1;
this.p8_1 = e;
}
}
while (true);
};
protoOf(parseMultipart$slambda).h2d = function ($this$produce, completion) {
var i = new parseMultipart$slambda(this.l2c_1, this.m2c_1, this.n2c_1, this.o2c_1, completion);
i.p2c_1 = $this$produce;
return i;
};
function parseMultipart$slambda_0($input, $boundaryPrefixed, $maxPartSize, $totalLength, resultContinuation) {
var i = new parseMultipart$slambda($input, $boundaryPrefixed, $maxPartSize, $totalLength, resultContinuation);
var l = function ($this$produce, $completion) {
return i.g2d($this$produce, $completion);
};
l.$arity = 1;
return l;
}
function $parsePartHeadersImplCOROUTINE$(input, resultContinuation) {
CoroutineImpl.call(this, resultContinuation);
this.l2a_1 = input;
}
protoOf($parsePartHeadersImplCOROUTINE$).u8 = function () {
var suspendResult = this.o8_1;
$sm: do
try {
var tmp = this.m8_1;
switch (tmp) {
case 0:
this.n8_1 = 3;
this.m2a_1 = new CharArrayBuilder();
this.n8_1 = 2;
this.m8_1 = 1;
suspendResult = parseHeaders(this.l2a_1, this.m2a_1, VOID, this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 1:
var tmp0_elvis_lhs = suspendResult;
var tmp_0;
if (tmp0_elvis_lhs == null) {
throw EOFException_init_$Create$('Failed to parse multipart headers: unexpected end of stream');
} else {
tmp_0 = tmp0_elvis_lhs;
}
return tmp_0;
case 2:
this.n8_1 = 3;
var tmp_1 = this.p8_1;
if (tmp_1 instanceof Error) {
var t = this.p8_1;
this.m2a_1.m28();
throw t;
} else {
throw this.p8_1;
}
case 3:
throw this.p8_1;
}
} catch ($p) {
var e = $p;
if (this.n8_1 === 3) {
throw e;
} else {
this.m8_1 = this.n8_1;
this.p8_1 = e;
}
}
while (true);
};
function $parsePartBodyImplCOROUTINE$(boundaryPrefixed, input, output, headers, limit, resultContinuation) {
CoroutineImpl.call(this, resultContinuation);
this.v2a_1 = boundaryPrefixed;
this.w2a_1 = input;
this.x2a_1 = output;
this.y2a_1 = headers;
this.z2a_1 = limit;
}
protoOf($parsePartBodyImplCOROUTINE$).u8 = function () {
var suspendResult = this.o8_1;
$sm: do
try {
var tmp = this.m8_1;
switch (tmp) {
case 0:
this.n8_1 = 6;
var tmp_0 = this;
var tmp0_safe_receiver = this.y2a_1.pd('Content-Length');
tmp_0.a2b_1 = tmp0_safe_receiver == null ? null : parseDecLong(tmp0_safe_receiver);
if (this.a2b_1 == null) {
this.m8_1 = 3;
suspendResult = readUntil(this.w2a_1, this.v2a_1, this.x2a_1, this.z2a_1, true, this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
} else {
if ((new Long(0, 0)).a3(this.z2a_1).hi(this.a2b_1)) {
this.m8_1 = 1;
suspendResult = copyTo(this.w2a_1, this.x2a_1, this.a2b_1, this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
} else {
var tmp_1 = this;
throwLimitExceeded(this.a2b_1, this.z2a_1);