Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for chunked modifications #164

Closed
wants to merge 1 commit into from
Closed

Conversation

vankoven
Copy link
Contributor

No description provided.

Copy link
Contributor

@krizhanovsky krizhanovsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understood correctly, there are no tests for h2 clients and responses with trailing headers.

class RemoveChunked(tester.TempestaTest):
"""Remodve chunked encoding from http/1 responses and correctly frame them
as h2 messages. Currently we have no good checker for http2 as deproxy,
just cun curl and see if it's happy with the received response.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
just cun curl and see if it's happy with the received response.
just run curl and see if it's happy with the received response.

"""

class RemoveChunked(tester.TempestaTest):
"""Remodve chunked encoding from http/1 responses and correctly frame them
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""Remodve chunked encoding from http/1 responses and correctly frame them
"""Remove chunked encoding from http/1 responses and correctly frame them

Transform payload to chunked encoding.
Transform HTTP/1 payload to chunked encoding.

Tempesta always cuts chunked encoding and adds it back for chunked messages.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably this won't be true with tempesta-tech/tempesta#1418 . Please consider the way #1418 will be fixed and correct the comment.

"""
Every response in chunked encoding losing chunked encoding during message
parsing and then it's added only if client is talking http/1 protocol.
Chunked body looks different in than case: only firs and last chunk
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Chunked body looks different in than case: only firs and last chunk
Chunked body looks different in than case: only first and last chunk

'Date: %s\r\n'
'\r\n%s\r\n'
% (date, chunked_body))
srv.set_response(resp)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the trailer headers tests are implemented for HTTP/1 clients only, but #1410.2 mentions the problem about caching responses with trailer headers. Please implement trailer headers tests for h2 as well. At least need to test (1) responses with trailer headers directly proxied to an h2 client and (2) response with trailed header is firstly cached by h1 request and next returned to an h2 client.

@const-t
Copy link
Contributor

const-t commented Oct 1, 2022

To compliance PR 1418 need to change existing tests and develop additional that will verify following rules:

  1. Transfer-Encoding header and chunked body must be removed from responses to HTTP2 clients and from all cacheable responses. Non-cacheable HTTP1 responses must be forwarded without changes. That implies response received from the cache or response forwards to HTTP2 client must not contain Transfer-Encoding header and chunked body must be cleared of chunks also this response must contain correct Content-Length header. Test must include cases:
  • Response to HTTP2 client or cacheable has multiple Transfer-Encoding headers E.g Transfer-Encoding: gzip\r\nTransfer-Encoding: chunked\r\n.
  • Response to HTTP2 client or cacheable has trailer. All headers from trailer must be moved to response headers when response received from cache or response forwarded to HTTP2 client. Need to test two types of headers from static table and that which not contains in static table.
  • Response to HTTP2 client or cacheable with chunked body has chunked extension. Extension must be removed.
  • Response to HTTP2 client or cacheable has zero chunked body. It implies chunked body have only trailing zero. It's a valid response it must be "dechunked" and forwarded.
  1. Responses from backend that don't contain Content-Length header and in same time have Transfer-Encoding header with chunked encoding as not the last encoding must not be placed into the cache. Tempesta must add Content-Length to such responses determining length of the body by closing the connection by backend.
  2. If response from backend contains Transfer-Encoding other than chunked and Content-Encoding such responses are valid and must be forwarded to client.
  3. Request that contains Transfer-Encoding: chunked and Content-Length in same time - must be blocked.
  4. Request that contains chunked encoding and chunked is not final encoding - must be blocked.

@const-t
Copy link
Contributor

const-t commented Oct 25, 2022

  1. The test to verify correctness of copying values from Transfer-Encoding header to Content-Encoding header for HTTP2 client. Backend sending response with Transfer-Encoding: gzip, br, chunked as result client must receive Content-Encoding: gzip,br

@nickzaev
Copy link
Contributor

nickzaev commented Nov 8, 2022

All tests mentioned in the comment above were implemented in #310, this one PR doesn't need to be merged.

@nickzaev nickzaev closed this Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants