#2639 web: return correct content-length
Merged a year ago by tkopecek. Opened a year ago by tkopecek.
tkopecek/koji issue2638  into  master

@@ -341,12 +341,13 @@ 

          environ['koji.values'].setdefault('mavenEnabled', False)

          environ['koji.values'].setdefault('winEnabled', False)

          result = _genHTML(environ, 'error.chtml')

+         result = self._tobytes(result)

          headers = [

              ('Allow', 'GET, POST, HEAD'),

-             ('Content-Length', str(len(result))),

+             ('Content-Length', str(len(result[0]))),

              ('Content-Type', 'text/html'),

          ]

-         return self._tobytes(result), headers

+         return result, headers

  

      def _tobytes(self, result):

          if isinstance(result, str):
@@ -400,13 +401,15 @@ 

                  # last one wins

                  headers[key] = (name, value)

          if isinstance(result, str):

-             headers.setdefault('content-length', ('Content-Length', str(len(result))))

+             result = self._tobytes(result)

+             headers.setdefault('content-length',

+                                ('Content-Length', str(len(result[0]))))

          headers.setdefault('content-type', ('Content-Type', 'text/html'))

          headers = list(headers.values()) + extra

          self.logger.debug("Headers:")

          self.logger.debug(koji.util.LazyString(pprint.pformat, [headers]))

          start_response(status, headers)

-         return self._tobytes(result)

+         return result

  

      def application(self, environ, start_response):

          """wsgi handler"""

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

a year ago

Metadata Update from @jobrauer:
- Pull-request untagged with: testing-ready
- Pull-request tagged with: testing-done

a year ago

Metadata Update from @jobrauer:
- Pull-request tagged with: testing-ready

a year ago

in handle_request you're calculating self._tobytes(result) twice.

other than that, looks good

rebased onto f655214047f2a0023745a009b36891484ae4cb91

a year ago

Metadata Update from @tkopecek:
- Pull-request untagged with: testing-done

a year ago

Metadata Update from @jobrauer:
- Pull-request tagged with: testing-done

a year ago

rebased onto 7479023

a year ago

Commit fba9c12 fixes this pull-request

Pull-Request has been merged by tkopecek

a year ago