݆X      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVW  None3579NXSequence of steps to get a StreamWorker. This class is independent of things like the finer details concerning the frames and the streams.]Todo: although this shows a common pattern, I'm not sure how having a class here helps....YiA StreamWorker: a conduit that takes input tokens and answers with output tokens. It can perform I/O.XZ[\Y]^_`abcdefghijklmnopXZ[\Y]^_`abcdefghijklmno XZ[\Y]^_`abcdefghijklmnopNone4IN nCallbacks that you can provide your sessions to notify you of interesting things happening in the server. ^Used by this session engine to report an error at some component, in a particular session. Components at an individual session. Used to report where in the session an error was produced. This interface is likely to change in the future, as we add more metadata to exceptions 3Information used to identify a particular session. Get/set a numeric Id from a  [. For example, to get the session id with this, import `Control.Lens.(^.)` and then do 3 session_id = session_coordinates ^. sessionId This is a temporal interface, but an useful one nonetheless. By setting some values here to True, second-transfer will add some headers to inbound requests, and some headers to outbound requests. VAdds a second-transfer-eh--used-protocol header to inbound requests. Default: False?Configuration information you can provide to the session maker.Session callbacks+Don't insert any extra-headers by default. TCreates a default sessions context. Modify as needed using the lenses interfaces q       q  None4INContains information that applies to all sessions created in the program. Use the lenses interface to access members of this struct. rstuvwx rstuvwxrstuvwxNone  Noneyz{%How to know if we can split somewhereInput left-oversGenerator action+Packet and leftovers, if we could get them |%How to know if we can split somewhereInput left-oversGenerator actionPacket bytes and left-overs.}~yz{|~yz{|}~ Safe+;NA function which takes three arguments: the first one says how to send data (on a socket or similar transport), and the second one how to receive data on the transport. The third argument encapsulates the sequence of steps needed for a clean shutdown. qYou can implement one of these to let somebody else supply the push, pull and close callbacks. For example, tlsServeWithALPN' will supply these arguments to an . Attendants encapsulate all the session book-keeping functionality, which for HTTP/2 is quite complicated. You use the functions http**Attendant to create one of these from a .:This library supplies two of such Attendant factories,  for HTTP 1.1 sessions, and   for HTTP/2 sessions.Callback that the session calls to realease resources associated with the channels. Take into account that your callback should be able to deal with non-clean shutdowns also, for example, if the connection to the remote peer is severed suddenly.uCallback type to pull data from a channel. The same as to PushAction applies to exceptions thrown from there. mCallback type to push data to a channel. Part of this interface is the abstract exception type IOProblem. Throw an instance of it from here to notify the session that the connection has been broken. There is no way to signal "normal termination", since HTTP/2's normal termination can be observed at a higher level when a GO_AWAY frame is seen. Safe+;N 'This exception will be raised inside a CoherentWorker when the underlying stream is cancelled (STREAM_RESET in HTTP/2). Do any necessary cleanup in a handler, or simply use the fact that the exception is asynchronously delivered to your CoherentWorker Haskell thread, giving you an opportunity to interrupt any blocked operations."sA concrete case of the above exception. Throw one of this if you don't want to implement your own type. Use $ in catch signatures.$)Throw exceptions derived from this (e.g, "? below) to have the HTTP/2 session to terminate gracefully. (Thrown with HTTP 1.1 over HTTP1.1 sessions when the response body or the request body doesn't include a Content-Length header field, even if it should have included it *Abstract exception. All HTTP/1.1 related exceptions derive from here. Notice that this includes a lot of logical errors and they can be raised when handling HTTP/2 sessions also,OThrown when the HTTP/2 connection prefix doesn't match the expected prefix..BAbstract exception. Thrown when encoding/decoding of a frame fails0Concrete exception. Used internally to signal that the client violated the protocol. Clients of the library shall never see this exception.2;Abstract exception. All HTTP/2 exceptions derive from here ( !"#$%&'()*+,-./0123 !"#$%&'()*+,-./012323./,-*+&'()$%"# !01 !"#$%&'()*+,-./0123None4Activates logging to terminalProtect logging with a mutex... that is to say, this is a horrible hack and you should try to log as little as possible or nothing at all. This just works for instrumentation locks...%Used internally to avoid garbled logs444None+5,Singleton type. Used in conjunction with an '. If the MVar is full, the fuction :I knows that it should finish at its earliest convenience and call the  for any open sessions.7Exceptions inheriting from $. This is thrown by the OpenSSL subsystem to signal that the connection was broken or that otherwise there was a problem at the SSL layer. 9Simple function to open :Interruptible version of 9. Use the extra argument to ask the server to finish: you pass an empty MVar and when you want to finish you just populate it. 56789APath to a certificate the server is going to use to identify itself. Bear in mind that multiple domains can be served from the same HTTP/2 TLS socket, so please create the HTTP/2 certificate accordingly. Also, currently this function only accepts paths to certificates or certificate chains in .pem format. %Path to the key of your certificate. AName of the network interface where you want to start your server-List of protocol names and the corresponding  to use for each. This way you can serve both HTTP/1.1 over TLS and HTTP/2 in the same socket. When no ALPN negotiation is present during the negotiation, the first protocol in this list is used.(Port to open to listen for connections. : Same as for 9  Same as for 9 Same as for 9 Same as for 94Finish request, write a value here to finish serving56789:56789:NoneC  None +3579N;A pushed stream, represented by a list of request headers, a list of response headers, and the usual response body (which may include final footers (not implemented yet)).<(A list of pushed streams. Notice that a list of IO computations is required here. These computations only happen when and if the streams are pushed to the client. The lazy nature of Haskell helps to avoid unneeded computations if the streams are not going to be sent to the client.=HMain type of this library. You implement one of these for your server. Basically this is a callback that the library calls as soon as it has all the headers of a request. For GET requests that's the entire request basically, but for POST and PUT requests this is just before the data starts arriving to the server. It is important that you consume the data in the cases where there is an input stream, otherwise the memory is lost for the duration of the request, and a malicious client can use that.rAlso, notice that when handling requests your worker can be interrupted with an asynchronous exception of type StreamCancelledException#, if the peer cancels the stream>A source-like conduit with the data returned in the response. The return value of the conduit is a list of footers. For now that list can be anything (even bottom), I'm not handling it just yet. ?+You use this type to answer a request. The DV are thus response headers and they should contain the :status pseudo-header. The <N is a list of pushed streams...(I don't thaink that I'm handling those yet)@Finalization headers AFinalization headers. If you don't know what they are, chances are that you don't need to worry about them for now. The support in this library for those are at best sketchy. BA request is a set of headers and a request body.... which will normally be empty, except for POST and PUT requests. But this library enforces none of that. CThis is a Source conduit (see Haskell Data.Conduit library from Michael Snoyman) that you can use to retrieve the data sent by the client piece-wise. DtList of headers. The first part of each tuple is the header name (be sure to conform to the HTTP/2 convention of using lowercase) and the second part is the headers contents. This list needs to include the special :method, :scheme, :authority and :path pseudo-headers for requests; and :status (with a plain numeric value represented in ascii digits) for responses.EThe complete headerFThe value part of a headerGThe name part of a headerH"Gets a single header from the listIIf you want to skip the footers, i.e., they are empty, use this function to convert an ordinary Source to a DataAndConclusion.;<=>?@ABCDEFGHI;<=>?@ABCDEFGHI;<=>?@ABCDEFGHINone;<=>?@ABCDEFGHIHIGFEDAB@=?<;>CNoneJIf you are not processing the potential POST input in a request, use this consumer to drop the data to oblivion. Otherwise it will remain in an internal queue until the client closes the stream, and if the client doesn't want to do so....JJJJNoneIN KAbstract data-type. Use P to get one of these from D<. The underlying representation admits better asymptotics.LPHTTP headers are case-insensitive, so we can use lowercase versions everywhereM!Checks that headers are lowercaseOLooks for a given headerP O(n*log n) Builds the editor from a list. QO(n)' Takes the HeaderEditor back to HeadersRTreplaceHeaderValue headers header_name maybe_header_value looks for header_name. If header_name is found and maybe_header_value is nothing, it returns a new headers list with the header deleted. If header_name is found and header_value is Just new_value, it returns a new list with the header containing the new value. If header_name is not in headers and maybe_header_value is Nothing, it returns the original headers list. If header_name is not in headers and maybe_header_value is Just new_value, it returns a new list where the last element is (header_name, new_value)SheaderLens header_name represents a lens into the headers, and you can use it then to add, alter and remove headers. It uses the same semantics than RTReplaces a "host" HTTP/1.1 header by an ":authority" HTTP/2 header. The list is expected to be already in lowercase, so nothing will happen if there the header name portion is "Host" instead of "host".Notice that having a HostR header in an HTTP/2 message is perfectly valid in certain circumstances, check  7https://http2.github.io/http2-spec/#rfc.section.8.1.2.3Section 8.1.2.3 of the spec for details.U$Given a header editor, introduces a DateC header. This function has a side-effect: to get the current timeKLMNOPQRSTU KLMNOPQRSTU LMNOKPQSRTUKLMNOPQRSTUNone4INc      !"#$%&'" D      !"#$%&'None*+352()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXY,AKL#( )*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYNone|LNoneZiStop condition when parsing the body. Right now only length is supported, given with Content-Length. ZTODO: Support "chunked" transfer encoding for classical HTTP/1.1, uploads will need it.[Was the parser complete?\DNo, not even headers are done. Use the returned value to continue]Headers were completed. For some HTTP methods that's all there is, and that's what this case represents. The second argument is a left-overs string.^For requests with a body. The second argument is a condition to stop receiving the body, the third is leftovers from parsing the headers._@Some requests are mal-formed. We can check those cases here.&`abZc[\]^_defghijklmnopqrstuvwxyz{|}~Zc[\]^_eijlop|}`abZc[\]^_defghijklmnopqrstuvwxyz{|}~NoneV&Session attendant that speaks HTTP/1.1VVVNone456789:9:47856NoneW+The type of this function is equivalent to: [ http2Attendant :: CoherentWorker -> PushAction -> PullAction -> CloseAction -> IO () Given a =r, this function wraps it with flow control, multiplexing, and state maintenance needed to run an HTTP/2 session. }Notice that this function is using HTTP/2 over TLS. We haven't implemented yet a session handling mechanism for HTTP/1.1 . WWW NoneWWNoneVV$(c) Alcides Viamontes Esquivel, 2015BSDalcidesv@zunzun.se experimentalPOSIXNone456789:;<=>?@ABCDEFGJVWDGFEB@=?<;>CAVW9:J78564 !"#$%%&''()**+,-./01 2 3 4 5 6 78899::;;<<==>>??@@AABCCDDEFGHIJKLMNOPQRSTUVWXYZ[\]^_` a b c d e f g h i j k l m n o p q r s s t u v w xy 2 z { | } ~    V      !"#$%&''()*+,-./012233456m789:;<=>?&@ABCDEFGHIJ"KLMNOPQRSTUVWXYZ[[\]^_`abcdefghijklmnopqrstusecon_9qQXDajnXfq3BOhHtDOFOxSecondTransfer.Sessions.ConfigSecondTransfer.SessionsSecondTransfer.TypesSecondTransfer.ExceptionSecondTransfer.MainLoopSecondTransfer.Utils.DevNull SecondTransfer.Utils.HTTPHeadersSecondTransfer.Http1SecondTransfer.Http2SecondTransfer.MainLoop.Tokens SecondTransfer.Sessions.InternalSecondTransfer.MainLoop.Framer$SecondTransfer.MainLoop.PushPullTypeCoherentWorkerhttp11Attendanthttp2AttendantSecondTransfer.MainLoop.Logging#SecondTransfer.MainLoop.OpenSSL_TLSSecondTransfer.Utils&SecondTransfer.MainLoop.CoherentWorkerSecondTransfer.Http2.SessionSecondTransfer.Http2.Framer SecondTransfer.MainLoop.InternalSecondTransfer.Http1.ParseSecondTransfer.Http1.Session"SecondTransfer.Http2.MakeAttendantSecondTransferSessionsCallbacks_reportErrorCallback ErrorCallbackSessionComponent(SessionInputThread_HTTP2SessionComponent0SessionHeadersOutputThread_HTTP2SessionComponent-SessionDataOutputThread_HTTP2SessionComponentFramer_HTTP2SessionComponentSession_HTTP11SessionCoordinates sessionIdSessionsEnrichedHeaders_addUsedProtocolreportErrorCallbackSessionsConfig_sessionsCallbacks_sessionsEnrichedHeadersaddUsedProtocoldefaultSessionsEnrichedHeaderssessionsCallbackssessionsEnrichedHeadersdefaultSessionsConfigSessionsContextmakeSessionsContext Attendant CloseAction PullAction PushActionStreamCancelledExceptionGenericIOProblem IOProblemHTTP11SyntaxExceptionContentLengthMissingExceptionHTTP11ExceptionBadPrefaceExceptionFramerExceptionHTTP2ProtocolExceptionHTTP2SessionExceptionenableConsoleLogging FinishRequestTLSLayerGenericProblemtlsServeWithALPN"tlsServeWithALPNAndFinishOnRequest PushedStream PushedStreamsDataAndConclusionPrincipalStreamFootersFinalizationHeadersRequestInputDataStreamHeadersHeader HeaderValue HeaderNamegetHeaderFromFlatList nullFooterdropIncomingData HeaderEditorlowercaseHeadersheadersAreLowercase!headersAreLowercaseAtHeaderEditor fetchHeaderfromListtoListreplaceHeaderValue headerLensreplaceHostByAuthorityintroduceDateHeaderStreamWorkerClass StreamWorker initService initSession initStreamStreamOutputActionSendHeaders_SOASendAssociatedHeaders_SOA SendData_SOASendAssociatedData_SOASendAssociatedFinish_SOA Finish_SOAGlobalStreamId LocalStreamIdStreamInputToken Headers_STkData_Stk Finish_StkUnpackedNameValueListactionIsForAssociatedStreampackHeaderTuplesunpackHeaderTuples getHeader$fBinaryUnpackedNameValueList$fEqSessionCoordinates_sessionsConfig_nextSessionId nextSessionIdsessionsConfigacquireNewSessionTagsessionExceptionHandlerLengthCallbackFramer readNextChunkreadNextChunkAndContinuereadUpTo readLength'convertHTTP2SessionExceptionToException%getHTTP2SessionExceptionFromException!convertFramerExceptionToExceptiongetFramerExceptionFromException!convertHTTP11ExceptionToExceptiongetHTTP11ExceptionFromException#$fExceptionStreamCancelledException$fExceptionGenericIOProblem$fExceptionIOProblem$fShowIOProblem $fExceptionHTTP11SyntaxException($fExceptionContentLengthMissingException$fExceptionHTTP11Exception$fShowHTTP11Exception$fExceptionBadPrefaceException$fExceptionFramerException$fShowFramerException!$fExceptionHTTP2ProtocolException $fExceptionHTTP2SessionException$fShowHTTP2SessionExceptiongloballyLogWelllogWithExclusivityconfigureLoggingToConsolesetLoggerLevelsbaseGHC.MVarMVar Protocols Wired_PtrConnection_PtrWired_t Connection_tInterruptibleEitherLeft_IRight_I InterruptedcloseConnectiondisposeWiredSessiongetSelectedProtocolrecvDatasendDatawaitForConnectionmakeConnectionallOk badHappenedtimeoutReached useBufferSizeprotocolsToWiredefaultWaitTime smallWaitTimeprovideActions!$fExceptionTLSLayerGenericProblemWord24strToInt word24ToInt getWord24be putWord24be lowercaseTextunfoldChannelAndSource stripString domainFromUrl subByteString$fBinaryWord24innerMap AutosortedtoFlatBsaTitleIsLowercasecolon$fOrdAutosortedWorkerThreadEnvironment _streamId_headersOutput _dataOutput_streamsCancelled_WTEDataOutputToConveyor HeadersSent InputFrame OutputFrameuseChunkLengthSessionSettings _pushEnabledPostInputMechanismCoherentSession SessionMakerSessionOutputCommandCancelSession_SOCSessionInputCommandFirstFrame_SICMiddleFrame_SICCancelSession_SIC WorkerMonadStream2HeaderBlockFragment HashTable SessionOutput SessionInputSession dataOutput headersOutputstreamIdstreamsCancelled_WTEsendMiddleFrameToSessionsendFirstFrameToSessionsendCommandToSessiongetFrameFromSession SessionData_sessionsContext _sessionInput_sessionOutput_toEncodeHeaders_toDecodeHeaders_receivingHeaders_lastGoodStream_stream2HeaderBlockFragment_forWorkerThread_coherentWorker_streamsCancelled_stream2PostInputMechanism_stream2WorkerThread_sessionIdAtSession_sessionSettings pushEnabledcoherentWorkerforWorkerThreadlastGoodStreamreceivingHeaderssessionIdAtSession sessionInput sessionOutputsessionSettingssessionsContextstream2HeaderBlockFragmentstream2PostInputMechanismstream2WorkerThreadstreamsCancelledtoDecodeHeaderstoEncodeHeaders http2SessionsessionInputThread sendOutFrameaddExtraHeadersvalidateIncomingHeaderscloseConnectionBecauseIsInvalidframeEndsStreamunlessReceivingHeaderscreateMechanismForStreamclosePostDataSourcestreamWorkerSendDatasendBytesToPimpostDataSourceFromMechanism isSettingsAckisStreamCancelled workerThreadsendDataOfStreamappendHeaderFragmentBlockgetHeaderBytesisAboutHeadersframeEndsHeadersstreamIdFromFrameheadersOutputThreadbytestringChunkdataOutputThreadFramerSessionData _stream2flow_stream2outputBytes_defaultStreamWindow _canOutput_outputIsForbidden_noHeadersInChannel _pushAction _closeAction _sessionId _lastStreamNoHeadersInChannel CanOutputStream2AvailSpaceFlowControlCommand AddBytes_FCMhttp2PrefixLength FramerSession canOutput closeActiondefaultStreamWindow lastStreamnoHeadersInChanneloutputIsForbidden pushAction stream2flowstream2outputBytes wrapSessionhttp2FrameLength addCapacity inputGathereroutputGathererupdateLastStreamstartStreamOutputQueuehandleHeadersOfStreamframeIsHeadersAndOpensStream pushFramesendGoAwayFrame sendBytesflowControlOutput releaseFramerBodyStopConditionHttp1ParserCompletionMustContinue_H1PCOnlyHeaders_H1PCHeadersAndBody_H1PCRequestIsMalformed_H1PCRequestOrResponseLine Request_RoRL Response_RoRLUseBodyLength_BSCHeaderParseClosureIncrementalHttp1Parser _fullText _stateParsernewIncrementalHttp1ParseraddByteselaborateHeaders splitByColonparseFirstLine bsToLowerstripBs locateCRLFstwoCRLFsAreConsecutiveisWsCh8isWs http1Token http1Method unspacedUrispace requestLinedigit responseLine httpFirstLineheaderListToHTTP11TextserializeHTTPResponsehttpStatusTable$fShowIncrementalHttp1Parser