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

Header cleanup #3404

Merged
merged 7 commits into from
Nov 23, 2018
Merged

Header cleanup #3404

merged 7 commits into from
Nov 23, 2018

Conversation

das7pad
Copy link
Contributor

@das7pad das7pad commented Nov 22, 2018

What do these changes do?

Fix import of cpython headers.

Drop invalid header start PROXY_.

Are there changes in behavior for the user?

No, this is a low level optimization.

Related issue number

The PR that introduced the header optimization: #3095

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt
    • The format is <Name> <Surname>.
    • Please keep alphabetical order, the file is sorted by names.
  • Add a new news fragment into the CHANGES folder
    • name it <issue_id>.<type> for example (588.bugfix)
    • if you don't have an issue_id change it to the pr id after creating the pr
    • ensure type is one of the following:
      • .feature: Signifying a new feature.
      • .bugfix: Signifying a bug fix.
      • .doc: Signifying a documentation improvement.
      • .removal: Signifying a deprecation or removal of public API.
      • .misc: A ticket has been closed, but it is not of interest to users.
    • Make sure to use full sentences with correct case and punctuation, for example: "Fix issue with non-ascii contents in doctest text files."

@codecov-io
Copy link

codecov-io commented Nov 22, 2018

Codecov Report

Merging #3404 into master will decrease coverage by 0.07%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3404      +/-   ##
==========================================
- Coverage   98.01%   97.94%   -0.08%     
==========================================
  Files          44       44              
  Lines        8500     8500              
  Branches     1377     1377              
==========================================
- Hits         8331     8325       -6     
- Misses         70       74       +4     
- Partials       99      101       +2
Impacted Files Coverage Δ
aiohttp/tcp_helpers.py 90% <0%> (-6.67%) ⬇️
aiohttp/web_fileresponse.py 96.51% <0%> (-1.75%) ⬇️
aiohttp/client_reqrep.py 97.28% <0%> (-0.16%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ffaef54...6483a09. Read the comment docs.

tools/gen.py Outdated
@@ -16,11 +15,17 @@ def factory():


TERMINAL = object()
HIDDEN_FROM_FIND_HEADER = (
'Proxy-Authorization',
Copy link
Member

Choose a reason for hiding this comment

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

Please elaborate why do you want to skip the header

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You dropped it manually in #3095. I just updated the build script to skip it there as well.

Here is the diff after running ./tools/gen.py on the master branch:

diff --git a/aiohttp/_find_header.c b/aiohttp/_find_header.c
index 3b656f9..71b8de4 100644
--- a/aiohttp/_find_header.c
+++ b/aiohttp/_find_header.c
@@ -6629,11 +6629,6 @@ PROX:
 PROXY:
     NEXT_CHAR();
     switch (ch) {
-        case '_':
-            if (last) {
-                return -1;
-            }
-            goto PROXY_;
         case '-':
             if (last) {
                 return -1;
@@ -6724,6 +6719,16 @@ PROXY_AUTH:
                 return -1;
             }
             goto PROXY_AUTHE;
+        case 'O':
+            if (last) {
+                return -1;
+            }
+            goto PROXY_AUTHO;
+        case 'o':
+            if (last) {
+                return -1;
+            }
+            goto PROXY_AUTHO;
         default:
             return -1;
     }
@@ -6847,6 +6852,142 @@ PROXY_AUTHENTICAT:
             return -1;
     }
 
+PROXY_AUTHO:
+    NEXT_CHAR();
+    switch (ch) {
+        case 'R':
+            if (last) {
+                return -1;
+            }
+            goto PROXY_AUTHOR;
+        case 'r':
+            if (last) {
+                return -1;
+            }
+            goto PROXY_AUTHOR;
+        default:
+            return -1;
+    }
+
+PROXY_AUTHOR:
+    NEXT_CHAR();
+    switch (ch) {
+        case 'I':
+            if (last) {
+                return -1;
+            }
+            goto PROXY_AUTHORI;
+        case 'i':
+            if (last) {
+                return -1;
+            }
+            goto PROXY_AUTHORI;
+        default:
+            return -1;
+    }
+
+PROXY_AUTHORI:
+    NEXT_CHAR();
+    switch (ch) {
+        case 'Z':
+            if (last) {
+                return -1;
+            }
+            goto PROXY_AUTHORIZ;
+        case 'z':
+            if (last) {
+                return -1;
+            }
+            goto PROXY_AUTHORIZ;
+        default:
+            return -1;
+    }
+
+PROXY_AUTHORIZ:
+    NEXT_CHAR();
+    switch (ch) {
+        case 'A':
+            if (last) {
+                return -1;
+            }
+            goto PROXY_AUTHORIZA;
+        case 'a':
+            if (last) {
+                return -1;
+            }
+            goto PROXY_AUTHORIZA;
+        default:
+            return -1;
+    }
+
+PROXY_AUTHORIZA:
+    NEXT_CHAR();
+    switch (ch) {
+        case 'T':
+            if (last) {
+                return -1;
+            }
+            goto PROXY_AUTHORIZAT;
+        case 't':
+            if (last) {
+                return -1;
+            }
+            goto PROXY_AUTHORIZAT;
+        default:
+            return -1;
+    }
+
+PROXY_AUTHORIZAT:
+    NEXT_CHAR();
+    switch (ch) {
+        case 'I':
+            if (last) {
+                return -1;
+            }
+            goto PROXY_AUTHORIZATI;
+        case 'i':
+            if (last) {
+                return -1;
+            }
+            goto PROXY_AUTHORIZATI;
+        default:
+            return -1;
+    }
+
+PROXY_AUTHORIZATI:
+    NEXT_CHAR();
+    switch (ch) {
+        case 'O':
+            if (last) {
+                return -1;
+            }
+            goto PROXY_AUTHORIZATIO;
+        case 'o':
+            if (last) {
+                return -1;
+            }
+            goto PROXY_AUTHORIZATIO;
+        default:
+            return -1;
+    }
+
+PROXY_AUTHORIZATIO:
+    NEXT_CHAR();
+    switch (ch) {
+        case 'N':
+            if (last) {
+                return 51;
+            }
+            goto PROXY_AUTHORIZATION;
+        case 'n':
+            if (last) {
+                return 51;
+            }
+            goto PROXY_AUTHORIZATION;
+        default:
+            return -1;
+    }
+
 R:
     NEXT_CHAR();
     switch (ch) {
@@ -9827,6 +9968,7 @@ MAX_FORWARDS:
 ORIGIN:
 PRAGMA:
 PROXY_AUTHENTICATE:
+PROXY_AUTHORIZATION:
 RANGE:
 REFERER:
 RETRY_AFTER:

Copy link
Member

Choose a reason for hiding this comment

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

Ah, thanks.
I don't recall details but IMHO there is no reason for Proxy-Authorization header skipping.

Please revert skipping logic in gen.py and regenerate _find_headers.c

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@asvetlov asvetlov merged commit b62d5fa into aio-libs:master Nov 23, 2018
@asvetlov
Copy link
Member

Thanks!

@das7pad das7pad deleted the hdrs-cleanup branch November 23, 2018 15:08
@lock
Copy link

lock bot commented Nov 23, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Nov 23, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Nov 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants