<commit_before>(ns fortress.ring.spdy
  (:import [fortress.util NettyUtil]
           [fortress.ring.spdy SpdyChunkedWriteHandler SpdyResponseStreamIdHandler]
           [fortress.ring.http MultipartDiskHandler]
           [io.netty.handler.stream ChunkedWriteHandler]
           [io.netty.handler.codec.spdy InstrumentedSpdyHttpDecoder]
           [org.eclipse.jetty.npn NextProtoNego]))

(gen-class :name fortress.ring.spdy.DefaultSpdyOrHttpChooser
           :extends io.netty.handler.codec.spdy.SpdyOrHttpChooser
           :prefix "ch-"
           :init "init"
           :state state
           :exposes-methods {addSpdyHandlers parentAddSpdyHandlers
                             addHttpHandlers parentAddHttpHandlers}
           :constructors {[io.netty.channel.ChannelInboundHandler Integer Integer java.lang.String clojure.lang.IFn] [int int]})

(defn ch-init [handler max-spdy-content-length max-http-content-length temp-dir-path listener-builder]
  [[max-spdy-content-length max-http-content-length] {:handler handler
                                                      :max-http-content-length max-http-content-length
                                                      :max-spdy-content-length max-spdy-content-length
                                                      :temp-dir-path temp-dir-path
                                                      :listener-builder listener-builder}])

(defn ch-addSpdyHandlers [this ctx version]
  (let [state (.state this)
        {:keys [max-spdy-content-length temp-dir-path listener-builder]} state
        pipeline (NettyUtil/pipeline ctx)]
    (.parentAddSpdyHandlers this ctx version)
    (.addBefore pipeline "spdyHttpDecoder" "instrumentedSpdyHttpDecoder" (InstrumentedSpdyHttpDecoder.
                                                                           version
                                                                           max-spdy-content-length
                                                                           (java.io.File. temp-dir-path)
                                                                           listener-builder))
    (.remove pipeline "spdyHttpDecoder")
    (.addBefore pipeline "spdyStreamIdHandler" "fortressSpdyStreamIdHandler" (SpdyResponseStreamIdHandler.))
    (.remove pipeline "spdyStreamIdHandler")
    (.addBefore pipeline "httpRquestHandler" "chunkedWriter" (SpdyChunkedWriteHandler.))))

(defn ch-addHttpHandlers [this ctx]
  (let [state (.state this)
        {:keys [max-http-content-length temp-dir-path listener-builder]} state
        pipeline (NettyUtil/pipeline ctx)]
    (.parentAddHttpHandlers this ctx)
    (.addBefore pipeline "httpRquestHandler" "chunkedWriter" (ChunkedWriteHandler.))  
    (.addAfter pipeline "httpRquestDecoder" "multipart" (MultipartDiskHandler. (java.io.File. temp-dir-path)
                                                                            max-http-content-length
                                                                            (if-not (nil? listener-builder)<commit_msg>Deleting chunked write handler<commit_after>(ns fortress.ring.spdy
  (:import [fortress.util NettyUtil]
           [fortress.ring.spdy SpdyChunkedWriteHandler SpdyResponseStreamIdHandler]
           [fortress.ring.http MultipartDiskHandler]
           [io.netty.handler.stream ChunkedWriteHandler]
           [io.netty.handler.codec.spdy InstrumentedSpdyHttpDecoder]
           [org.eclipse.jetty.npn NextProtoNego]))

(gen-class :name fortress.ring.spdy.DefaultSpdyOrHttpChooser
           :extends io.netty.handler.codec.spdy.SpdyOrHttpChooser
           :prefix "ch-"
           :init "init"
           :state state
           :exposes-methods {addSpdyHandlers parentAddSpdyHandlers
                             addHttpHandlers parentAddHttpHandlers}
           :constructors {[io.netty.channel.ChannelInboundHandler Integer Integer java.lang.String clojure.lang.IFn] [int int]})

(defn ch-init [handler max-spdy-content-length max-http-content-length temp-dir-path listener-builder]
  [[max-spdy-content-length max-http-content-length] {:handler handler
                                                      :max-http-content-length max-http-content-length
                                                      :max-spdy-content-length max-spdy-content-length
                                                      :temp-dir-path temp-dir-path
                                                      :listener-builder listener-builder}])

(defn ch-addSpdyHandlers [this ctx version]
  (let [state (.state this)
        {:keys [max-spdy-content-length temp-dir-path listener-builder]} state
        pipeline (NettyUtil/pipeline ctx)]
    (.parentAddSpdyHandlers this ctx version)
    (.addBefore pipeline "spdyHttpDecoder" "instrumentedSpdyHttpDecoder" (InstrumentedSpdyHttpDecoder.
                                                                           version
                                                                           max-spdy-content-length
                                                                           (java.io.File. temp-dir-path)
                                                                           listener-builder))
    (.remove pipeline "spdyHttpDecoder")
    (.addBefore pipeline "spdyStreamIdHandler" "fortressSpdyStreamIdHandler" (SpdyResponseStreamIdHandler.))
    (.remove pipeline "spdyStreamIdHandler")))

(defn ch-addHttpHandlers [this ctx]
  (let [state (.state this)
        {:keys [max-http-content-length temp-dir-path listener-builder]} state
        pipeline (NettyUtil/pipeline ctx)]
    (.parentAddHttpHandlers this ctx)
    (.addBefore pipeline "httpRquestHandler" "chunkedWriter" (ChunkedWriteHandler.))  
    (.addAfter pipeline "httpRquestDecoder" "multipart" (MultipartDiskHandler. (java.io.File. temp-dir-path)
                                                                            max-http-content-length
                                                                            (if-not (nil? listener-builder)
{'fraction_non_alphanumeric': 0.08628099173553719, 'fraction_numerical': 0.0, 'mean_word_length': 1.616083009079118, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 52, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '902679', 'n_tokens_mistral': 1483, 'n_tokens_neox': 1452, 'n_words': 279}