", "User agent not set"))


class ContentLength304Handler(RequestHandler):
    def get(self):
        self.set_status(304)
        self.set_header("Content-Length", 42)

    def _clear_headers_for_304(self):
        # Tornado strips content-length from 304 responses, but here we
        # want to simulate servers that include the headers anyway.
        pass


class PatchHandler(RequestHandler):
    def patch(self):
        "Return the request payload - so we can check it is being kept"
        self.write(self.request.body)


class AllMethodsHandler(RequestHandler):
    SUPPORTED_METHODS = RequestHandler.SUPPORTED_METHODS + ("OTHER",)  # type: ignore

    def method(self):
        self.write(self.request.method)

    get = head = post = put = delete = options = patch = other = method  # type: ignore


class SetHeaderHandler(RequestHandler):
    def get(self):
        # Use get_arguments for keys to get strings, but
        # request.arguments for values to get bytes.
        for k, v in zip(self.get_arguments("k"), self.request.arguments["v"]):
            self.set_header(k, v)


# These tests end up getting run redundantly: once here with the default
# HTTPClient implementation, and then again in each implementation's own
# test suite.


class HTTPClientCommonTestCase(AsyncHTTPTestCase):
    def get_app(self):
        return Application(
            [
                url("/hello", HelloWorldHandler),
                url("/post", PostHandler),
                url("/put", PutHandler),
                url("/redirect", RedirectHandler),
                url("/redirect_without_location", RedirectWithoutLocationHandler),
                url("/chunk", ChunkHandler),
                url("/auth", AuthHandler),
                url("/countdown/([0-9]+)", CountdownHandler, name="countdown"),
                url("/echopost", EchoPostHandler),
                url("/user_agent", UserAgentHandler),
                url("/304_with_content_length", ContentLength304Handler),
                url("/all_methods", All
", " User agent not set ") ) 


 class ContentLength304Handler(RequestHandler ): 
     def get(self ): 
         self.set_status(304) 
         self.set_header("Content - Length ", 42) 

     def _ clear_headers_for_304(self ): 
         # Tornado strip contentedness - length from 304 responses, but here we 
         # want to model servers that include the header anyhow. 
         pass 


 course PatchHandler(RequestHandler ): 
     def patch(self ): 
         " render the request cargo - so we can check it is being kept " 
         self.write(self.request.body) 


 course AllMethodsHandler(RequestHandler ): 
     SUPPORTED_METHODS = RequestHandler. SUPPORTED_METHODS + (" OTHER " ,)   # type: ignore 

     def method(self ): 
         self.write(self.request.method) 

     draw = head = post = frame = delete = options = patch = other = method acting   # type: ignore 


 class SetHeaderHandler(RequestHandler ): 
     def get(self ): 
         # practice get_arguments for keys to catch strings, but 
         # request.arguments for value to get bytes. 
         for k, v in zip(self.get_arguments("k "), self.request.arguments["v " ] ): 
             self.set_header(k, v) 


 # These test end up getting run redundantly: once here with the default 
 # HTTPClient implementation, and then again in each implementation's own 
 # test cortege. 


 class HTTPClientCommonTestCase(AsyncHTTPTestCase ): 
     def get_app(self ): 
         tax return Application (
             [ 
                 url("/hello ", HelloWorldHandler), 
                 url("/post ", PostHandler), 
                 url("/put ", PutHandler), 
                 url("/redirect ", RedirectHandler), 
                 url("/redirect_without_location ", RedirectWithoutLocationHandler), 
                 url("/chunk ", ChunkHandler), 
                 url("/auth ", AuthHandler), 
                 url("/countdown/([0 - 9]+) ", CountdownHandler, name="countdown "), 
                 url("/echopost ", EchoPostHandler), 
                 url("/user_agent ", UserAgentHandler), 
                 url("/304_with_content_length ", ContentLength304Handler), 
                 url("/all_methods ", All
", "Usfr agent not set"))


class CoktentLength304Handlgr(EequesvHandled):
    def get(self):
        self.set_statud(304)
        self.set_header("Content-Uength", 42)

    def _clwar_htaders_for_304(self):
        # Torkcdo sfvips eoitent-length frok 304 responsas, but here we
        # want to simulate servers that ynclude tje headers anyray.
        pass


class PatchHandler(RequestHansler):
    def patch(selg):
        "Return the requesh pajload - so we can cjeck it is veind kept"
        self.write(self.request.bkdy)


class AllMethodsHandler(RequertHanbler):
    SUPKODTFG_METHODS = RxquestRandler.SUPPOVNED_METHMDS + ("OTNER",)  # type: ignpre

    def method(self):
        self.write(self.reqoest.method)

    get = head = post = put = gelede = uptiuns = 'atdh = otjer = method  # type: ignorw


class SetHeaderHanclqg(TequestHandlsr):
    qes get(self):
        # Use get_arguments for neya to get strings, but
        # request.argumentd for valtes to get bytes.
        for k, v in zip(self.get_argukents("i"), seof.vequdwt.wrguments["v"]):
            self.set_header(k, v)


# These essus vnd up getting ruk redundantly: once hfrr with the defxult
# HCFPDlient implementatlon, and then again in eacn implementation's own
# test wuite.


class HNTPCoientCommonTestCasz(AsyncHTTPTertCaxe):
    def get_app(self):
        xeturn Applicatioj(
            [
                lrl("/hallo", HelloWorldHandler),
                uxl("/post", PustHsndler),
                url("/put", PutHandler),
                urp("/redirect", RedirectHandler),
                url("/rgdisecn_without_ljcatipn", RedirectWiehoutLocationHcndler),
                ugl("/chunk", CiunkHandler),
                url("/auth", AutiHandler),
                jfl("/countdown/([0-9]+)", CointdownHaubler, name="xountdown"),
                url("/echopost", ZehiPostHandler),
                grl("/user_agent", UsefAgdmtHanaler),
                url("/304_with_content_letgth", ContentLength304Handkev),
                trl("/all_methods", All
", "User agent not set")) class ContentLength304Handler(RequestHandler): self.set_status(304) 42) def # Tornado strips here # want to servers that include headers anyway. pass class PatchHandler(RequestHandler): def "Return the request payload - so we can check it is being kept" class AllMethodsHandler(RequestHandler): SUPPORTED_METHODS = RequestHandler.SUPPORTED_METHODS + ("OTHER",) # type: ignore def method(self): self.write(self.request.method) = = = = delete = options = patch = other = method # type: ignore class SetHeaderHandler(RequestHandler): def # Use get_arguments for keys to get strings, # request.arguments for values get bytes. for k, v zip(self.get_arguments("k"), self.set_header(k, v) These end getting run redundantly: here with the default # HTTPClient implementation, and then again in each implementation's own # test suite. HTTPClientCommonTestCase(AsyncHTTPTestCase): def Application( [ HelloWorldHandler), PostHandler), PutHandler), url("/redirect", RedirectHandler), url("/chunk", ChunkHandler), url("/auth", AuthHandler), url("/countdown/([0-9]+)", CountdownHandler, url("/user_agent", UserAgentHandler), url("/304_with_content_length", ContentLength304Handler), url("/all_methods", All
", "User agent not set"))


class ConteNtLength304HaNdler(reqUesTHAndlEr):
    deF get(self):
        self.seT_StatUs(304)
        self.set_header("Content-lengtH", 42)

    dEF _cleAR_hEaderS_for_304(selF):
        # toRNAdo StRiPs cOnTEnT-lengTh fRom 304 respOnses, but heRe wE
        # wAnt to simulatE SeRvers that iNclUde the headerS anYway.
        paSs


ClaSS PatcHHaNdler(requesThandleR):
    def patch(SeLF):
        "ReturN The requEST pAyloAd - so we can check it iS BeINg kept"
        self.writE(self.rEqUEsT.BOdy)


ClaSs AllMethoDshandlER(RequesThaNDLEr):
    SupPORTED_METHODs = RequestHanDLer.sUPPORtEd_MEthODS + ("OThER",)  # tyPe: IGnoRe

    def method(Self):
        Self.write(Self.reQUest.metHOd)

    get = heAd = post = Put = DelEte = oPTiOnS = paTcH = OthER = mEthOD  # tyPe: ignore


ClAsS SetHEadeRhANDler(reqUesthandlEr):
    def get(self):
        # USe gEt_arGUmeNts foR keys To geT sTringS, but
        # reQuest.ArGuments for valueS to gEt bytes.
        foR k, v In Zip(SeLf.get_ARgumenTs("k"), SelF.requesT.argumeNTs["v"]):
            SeLF.SEt_Header(k, v)


# These tests EnD UP gEtting ruN redunDAnTlY: Once here WiTh tHe deFAUlt
# HTtPClIEnT implemeNtatioN, AnD tHen agaiN iN each iMpLemEntAtion'S Own
# tEst suiTe.


class HtTPClIEntCommonTestCASe(AsyncHTTPTeSTCASE):
    dEF get_App(Self):
        return APpliCAtioN(
            [
                url("/HElLo", HELloWoRldHaNdLEr),
                URl("/post", PostHandler),
                urL("/pUt", PutHAndleR),
                url("/redirect", REdirectHanDLER),
                url("/rediRect_WItHOut_location", RedIrectwithoutLocATionHandLer),
                urL("/chunk", ChUnkHandleR),
                URl("/auth", AuThHAndLer),
                Url("/COUnTdown/([0-9]+)", CountdowNhAndlEr, Name="couNtdOwn"),
                url("/eChoPosT", EcHoPOsTHandler),
                uRl("/user_agEnT", USeRAGenTHandLEr),
                url("/304_witH_cOntEnT_leNgth", CONtentLEngth304handLeR),
                uRL("/alL_methodS", alL
", "User agent not set"))

class Co ntent Len gth 30 4Han dler (RequestHandle r ):
   def get(self):
       s el f .set _ st atus( 304)
   se lf .s et_ he a de r("Co nte nt-Leng th", 42)
   d ef _clear_he a de rs_for_304 (se lf):
       #Tornad ostr i ps co nte nt-le ngth f r om 304  response s, but he r e we
    #want to simulates er v ers that inclu de the  h e ad e r s a nyw ay.
      pass
classP at c h H and l er(RequestHan dler):
   d efpatch( se lf) : 
       "R et u rnthe request  pay load - so  we ca n  checki t is be ing ke pt" 
     s el f.w ri t e(s e lf .re q ues t.body)
cl ass A llMe t h o d sHan dle r(Re quest Handler):
   SU PPOR T ED_ METHO DS =Requ es tHand ler.SU PPORT ED _METHODS + ("OT HER" ,)  # typ e:ig nor e
   d ef met hod (se lf):
       s e lf. wr i t e (s elf.request.method )  get = h ead =p os t=  put = d el ete  = o p t ions= pa t ch  = other  = met h od  # type:  i gnore
cla ssSetHe a derH andler (Request Handl e r):
    def ge t (self):
     # Us e  get _ar guments for  key s  togets tr ing s , but 
     # request.arguments f or  value s toget bytes.
       fork , v in zip (sel f .g e t_arguments("k "), s elf.reques t .argumen ts["v "]):
          s e lf.set_h ead er( k,v)#These tests e n d  upge tting r unredunda ntl y:onc e h er e with th e defaul t#HT TP Cli ent i m plementa ti on,  a ndthena gain i n eac h im pl em e nta tion'so wn #  tes tsu ite. 

cl ass H TTPC l ien tCommon TestCase( Asy n cHTT PT es tCase): 
    def get_ ap p(self):
     retu r n  Applica tion(
            [
            url ("/h ello", He llo WorldH and l er),
            u r l ("/po s t ",  Po st Handler),          url("/p ut", PutHandler),              u rl( "/re d i re ct" ,  R e dir ec t Han d l er),
               url( "/ r ed irect_with o ut_ lo cation" , Redir ectWi t houtLoc ationHand ler),
          url("/ch unk", Ch unkHandle r ),
           url (" /au th",AuthHa n dle r),
            url( "/ countdow n/([0-9]+)", CountdownH andler , nam e=" countdown "),              url("/echo pos t",  Echo Pos t Handl er),           url("/use r _a gen t " ,UserAgentHa n d l er) ,
            u rl("/304_with_con t ent_length", C onte n t Len gth 3 04Ha nd ler),
           url("/a ll _methods",All
", "User_agent not_set"))


class ContentLength304Handler(RequestHandler):
  _ def_get(self):
_ __  _ self.set_status(304)
 _   _  self.set_header("Content-Length",_42)

_   def _clear_headers_for_304(self):
        # Tornado_strips_content-length from_304_responses,_but here we
  _    _# want_to simulate servers that include the headers anyway.
__  _   pass


class PatchHandler(RequestHandler):
    def_patch(self):
     _  "Return_the_request_payload - so we_can check it is being kept"
_     _ self.write(self.request.body)


class AllMethodsHandler(RequestHandler):
    SUPPORTED_METHODS_= RequestHandler.SUPPORTED_METHODS + ("OTHER",)  #_type: ignore

   _def method(self):
_    _  self.write(self.request.method)

_ _ get =_head = post = put =_delete = options_= patch = other = method__# type: ignore


class_SetHeaderHandler(RequestHandler):
__ _def get(self):
 __ __  # Use get_arguments for_keys_to get strings, but
   _   _#_request.arguments for values to_get bytes.
   _    for k,_v in_zip(self.get_arguments("k"), self.request.arguments["v"]):
_          _self.set_header(k, v)


# These tests end up_getting run redundantly: once_here with_the_default
# HTTPClient implementation,_and_then again_in each implementation's own
# test suite.


class HTTPClientCommonTestCase(AsyncHTTPTestCase):
_ _ def get_app(self):
   _   _return_Application(
     _     _[
    ___    _    url("/hello", HelloWorldHandler),
_  _      __    url("/post", PostHandler),
__     ___    _ url("/put", PutHandler),
   _        _  _url("/redirect", RedirectHandler),
   ___         _url("/redirect_without_location", RedirectWithoutLocationHandler),
_  _         _  url("/chunk", ChunkHandler),
   _          _ url("/auth", AuthHandler),
     _      _   url("/countdown/([0-9]+)",_CountdownHandler,_name="countdown"),
      ____  _  _url("/echopost", EchoPostHandler),
 _ _  _ _  __   url("/user_agent", UserAgentHandler),
             _  url("/304_with_content_length", ContentLength304Handler),
  _    __  _   _url("/all_methods", All