Bug #2436

Content-Length should be set to 0 if httpReq method is POST and postdata is absent when calling it

Added by Leonid Protasov over 6 years ago. Updated over 6 years ago.

Status:InvalidStart date:12/30/2014
Priority:NormalDue date:
Assignee:Andreas Smas% Done:

0%

Category:API
Target version:4.8
Found in version:4.7.588 Platform:Linux

Description

This avoids error 411 from google servers

History

#1 Updated by Leonid Protasov over 6 years ago

  • Found in version changed from 4.7.585 to 4.7.588

Ignoring this results in:

HTTP            [DEBUG]: > POST /youtube/v3/videos/rate?id=eRcfW2KekaM&rating=like&key=AIzaSyCSDI9_w8ROa1UoE2CNIUdDQnUhNbp9XR4 HTTP/1.1
HTTP            [DEBUG]: > Authorization: Bearer ya29.7ADy2dEAzgGXHNU8sYejys13rQ7H4xLVOOZ0gBU-ix7pjY1fTtw61zICKYcxUJ4wkz1D0TsHJjqOXg
HTTP            [DEBUG]: > User-Agent: Showtime Linux/x86_64 4.7.588.gf21e9
HTTP            [DEBUG]: > Connection: keep-alive
HTTP            [DEBUG]: > Accept: */*
HTTP            [DEBUG]: > Accept-Encoding: identity
HTTP            [DEBUG]: > Host: www.googleapis.com
HTTP            [DEBUG]: https://www.googleapis.com/youtube/v3/videos/rate: Response:
HTTP            [DEBUG]: < HTTP/1.0 411 Length Required
HTTP            [DEBUG]: < Content-Type: text/html; charset=UTF-8
HTTP            [DEBUG]: < Content-Length: 1428
HTTP            [DEBUG]: < Date: Tue, 30 Dec 2014 17:17:10 GMT
HTTP            [DEBUG]: < Server: GFE/2.0
HTTP            [DEBUG]: < 
drain           [DEBUG]: 0x000000: 3c 21 44 4f 43 54 59 50  45 20 68 74 6d 6c 3e 0a    <!DOCTYPE html>.
drain           [DEBUG]: 0x000010: 3c 68 74 6d 6c 20 6c 61  6e 67 3d 65 6e 3e 0a 20    <html lang=en>. 
drain           [DEBUG]: 0x000020: 20 3c 6d 65 74 61 20 63  68 61 72 73 65 74 3d 75     <meta charset=u
drain           [DEBUG]: 0x000030: 74 66 2d 38 3e 0a 20 20  3c 6d 65 74 61 20 6e 61    tf-8>.  <meta na
drain           [DEBUG]: 0x000040: 6d 65 3d 76 69 65 77 70  6f 72 74 20 63 6f 6e 74    me=viewport cont
drain           [DEBUG]: 0x000050: 65 6e 74 3d 22 69 6e 69  74 69 61 6c 2d 73 63 61    ent="initial-sca
drain           [DEBUG]: 0x000060: 6c 65 3d 31 2c 20 6d 69  6e 69 6d 75 6d 2d 73 63    le=1, minimum-sc
drain           [DEBUG]: 0x000070: 61 6c 65 3d 31 2c 20 77  69 64 74 68 3d 64 65 76    ale=1, width=dev
drain           [DEBUG]: 0x000080: 69 63 65 2d 77 69 64 74  68 22 3e 0a 20 20 3c 74    ice-width">.  <t
drain           [DEBUG]: 0x000090: 69 74 6c 65 3e 45 72 72  6f 72 20 34 31 31 20 28    itle>Error 411 (
drain           [DEBUG]: 0x0000a0: 4c 65 6e 67 74 68 20 52  65 71 75 69 72 65 64 29    Length Required)
drain           [DEBUG]: 0x0000b0: 21 21 31 3c 2f 74 69 74  6c 65 3e 0a 20 20 3c 73    !!1</title>.  <s
drain           [DEBUG]: 0x0000c0: 74 79 6c 65 3e 0a 20 20  20 20 2a 7b 6d 61 72 67    tyle>.    *{marg
drain           [DEBUG]: 0x0000d0: 69 6e 3a 30 3b 70 61 64  64 69 6e 67 3a 30 7d 68    in:0;padding:0}h
drain           [DEBUG]: 0x0000e0: 74 6d 6c 2c 63 6f 64 65  7b 66 6f 6e 74 3a 31 35    tml,code{font:15
drain           [DEBUG]: 0x0000f0: 70 78 2f 32 32 70 78 20  61 72 69 61 6c 2c 73 61    px/22px arial,sa
drain           [DEBUG]: 0x000100: 6e 73 2d 73 65 72 69 66  7d 68 74 6d 6c 7b 62 61    ns-serif}html{ba
drain           [DEBUG]: 0x000110: 63 6b 67 72 6f 75 6e 64  3a 23 66 66 66 3b 63 6f    ckground:#fff;co
drain           [DEBUG]: 0x000120: 6c 6f 72 3a 23 32 32 32  3b 70 61 64 64 69 6e 67    lor:#222;padding
drain           [DEBUG]: 0x000130: 3a 31 35 70 78 7d 62 6f  64 79 7b 6d 61 72 67 69    :15px}body{margi
drain           [DEBUG]: 0x000140: 6e 3a 37 25 20 61 75 74  6f 20 30 3b 6d 61 78 2d    n:7% auto 0;max-
drain           [DEBUG]: 0x000150: 77 69 64 74 68 3a 33 39  30 70 78 3b 6d 69 6e 2d    width:390px;min-
drain           [DEBUG]: 0x000160: 68 65 69 67 68 74 3a 31  38 30 70 78 3b 70 61 64    height:180px;pad
drain           [DEBUG]: 0x000170: 64 69 6e 67 3a 33 30 70  78 20 30 20 31 35 70 78    ding:30px 0 15px
drain           [DEBUG]: 0x000180: 7d 2a 20 3e 20 62 6f 64  79 7b 62 61 63 6b 67 72    }* > body{backgr
drain           [DEBUG]: 0x000190: 6f 75 6e 64 3a 75 72 6c  28 2f 2f 77 77 77 2e 67    ound:url(//www.g
drain           [DEBUG]: 0x0001a0: 6f 6f 67 6c 65 2e 63 6f  6d 2f 69 6d 61 67 65 73    oogle.com/images
drain           [DEBUG]: 0x0001b0: 2f 65 72 72 6f 72 73 2f  72 6f 62 6f 74 2e 70 6e    /errors/robot.pn
drain           [DEBUG]: 0x0001c0: 67 29 20 31 30 30 25 20  35 70 78 20 6e 6f 2d 72    g) 100% 5px no-r
drain           [DEBUG]: 0x0001d0: 65 70 65 61 74 3b 70 61  64 64 69 6e 67 2d 72 69    epeat;padding-ri
drain           [DEBUG]: 0x0001e0: 67 68 74 3a 32 30 35 70  78 7d 70 7b 6d 61 72 67    ght:205px}p{marg
drain           [DEBUG]: 0x0001f0: 69 6e 3a 31 31 70 78 20  30 20 32 32 70 78 3b 6f    in:11px 0 22px;o
drain           [DEBUG]: 0x000200: 76 65 72 66 6c 6f 77 3a  68 69 64 64 65 6e 7d 69    verflow:hidden}i
drain           [DEBUG]: 0x000210: 6e 73 7b 63 6f 6c 6f 72  3a 23 37 37 37 3b 74 65    ns{color:#777;te
drain           [DEBUG]: 0x000220: 78 74 2d 64 65 63 6f 72  61 74 69 6f 6e 3a 6e 6f    xt-decoration:no
drain           [DEBUG]: 0x000230: 6e 65 7d 61 20 69 6d 67  7b 62 6f 72 64 65 72 3a    ne}a img{border:
drain           [DEBUG]: 0x000240: 30 7d 40 6d 65 64 69 61  20 73 63 72 65 65 6e 20    0}@media screen 
drain           [DEBUG]: 0x000250: 61 6e 64 20 28 6d 61 78  2d 77 69 64 74 68 3a 37    and (max-width:7
drain           [DEBUG]: 0x000260: 37 32 70 78 29 7b 62 6f  64 79 7b 62 61 63 6b 67    72px){body{backg
drain           [DEBUG]: 0x000270: 72 6f 75 6e 64 3a 6e 6f  6e 65 3b 6d 61 72 67 69    round:none;margi
drain           [DEBUG]: 0x000280: 6e 2d 74 6f 70 3a 30 3b  6d 61 78 2d 77 69 64 74    n-top:0;max-widt
drain           [DEBUG]: 0x000290: 68 3a 6e 6f 6e 65 3b 70  61 64 64 69 6e 67 2d 72    h:none;padding-r
drain           [DEBUG]: 0x0002a0: 69 67 68 74 3a 30 7d 7d  23 6c 6f 67 6f 7b 62 61    ight:0}}#logo{ba
drain           [DEBUG]: 0x0002b0: 63 6b 67 72 6f 75 6e 64  3a 75 72 6c 28 2f 2f 77    ckground:url(//w
drain           [DEBUG]: 0x0002c0: 77 77 2e 67 6f 6f 67 6c  65 2e 63 6f 6d 2f 69 6d    ww.google.com/im
drain           [DEBUG]: 0x0002d0: 61 67 65 73 2f 65 72 72  6f 72 73 2f 6c 6f 67 6f    ages/errors/logo
drain           [DEBUG]: 0x0002e0: 5f 73 6d 5f 32 2e 70 6e  67 29 20 6e 6f 2d 72 65    _sm_2.png) no-re
drain           [DEBUG]: 0x0002f0: 70 65 61 74 7d 40 6d 65  64 69 61 20 6f 6e 6c 79    peat}@media only
drain           [DEBUG]: 0x000300: 20 73 63 72 65 65 6e 20  61 6e 64 20 28 6d 69 6e     screen and (min
drain           [DEBUG]: 0x000310: 2d 72 65 73 6f 6c 75 74  69 6f 6e 3a 31 39 32 64    -resolution:192d
drain           [DEBUG]: 0x000320: 70 69 29 7b 23 6c 6f 67  6f 7b 62 61 63 6b 67 72    pi){#logo{backgr
drain           [DEBUG]: 0x000330: 6f 75 6e 64 3a 75 72 6c  28 2f 2f 77 77 77 2e 67    ound:url(//www.g
drain           [DEBUG]: 0x000340: 6f 6f 67 6c 65 2e 63 6f  6d 2f 69 6d 61 67 65 73    oogle.com/images
drain           [DEBUG]: 0x000350: 2f 65 72 72 6f 72 73 2f  6c 6f 67 6f 5f 73 6d 5f    /errors/logo_sm_
drain           [DEBUG]: 0x000360: 32 5f 68 72 2e 70 6e 67  29 20 6e 6f 2d 72 65 70    2_hr.png) no-rep
drain           [DEBUG]: 0x000370: 65 61 74 20 30 25 20 30  25 2f 31 30 30 25 20 31    eat 0% 0%/100% 1
drain           [DEBUG]: 0x000380: 30 30 25 3b 2d 6d 6f 7a  2d 62 6f 72 64 65 72 2d    00%;-moz-border-
drain           [DEBUG]: 0x000390: 69 6d 61 67 65 3a 75 72  6c 28 2f 2f 77 77 77 2e    image:url(//www.
drain           [DEBUG]: 0x0003a0: 67 6f 6f 67 6c 65 2e 63  6f 6d 2f 69 6d 61 67 65    google.com/image
drain           [DEBUG]: 0x0003b0: 73 2f 65 72 72 6f 72 73  2f 6c 6f 67 6f 5f 73 6d    s/errors/logo_sm
drain           [DEBUG]: 0x0003c0: 5f 32 5f 68 72 2e 70 6e  67 29 20 30 7d 7d 40 6d    _2_hr.png) 0}}@m
drain           [DEBUG]: 0x0003d0: 65 64 69 61 20 6f 6e 6c  79 20 73 63 72 65 65 6e    edia only screen
drain           [DEBUG]: 0x0003e0: 20 61 6e 64 20 28 2d 77  65 62 6b 69 74 2d 6d 69     and (-webkit-mi
drain           [DEBUG]: 0x0003f0: 6e 2d 64 65 76 69 63 65  2d 70 69 78 65 6c 2d 72    n-device-pixel-r
drain           [DEBUG]: 0x000400: 61 74 69 6f 3a 32 29 7b  23 6c 6f 67 6f 7b 62 61    atio:2){#logo{ba
drain           [DEBUG]: 0x000410: 63 6b 67 72 6f 75 6e 64  3a 75 72 6c 28 2f 2f 77    ckground:url(//w
drain           [DEBUG]: 0x000420: 77 77 2e 67 6f 6f 67 6c  65 2e 63 6f 6d 2f 69 6d    ww.google.com/im
drain           [DEBUG]: 0x000430: 61 67 65 73 2f 65 72 72  6f 72 73 2f 6c 6f 67 6f    ages/errors/logo
drain           [DEBUG]: 0x000440: 5f 73 6d 5f 32 5f 68 72  2e 70 6e 67 29 20 6e 6f    _sm_2_hr.png) no
drain           [DEBUG]: 0x000450: 2d 72 65 70 65 61 74 3b  2d 77 65 62 6b 69 74 2d    -repeat;-webkit-
drain           [DEBUG]: 0x000460: 62 61 63 6b 67 72 6f 75  6e 64 2d 73 69 7a 65 3a    background-size:
drain           [DEBUG]: 0x000470: 31 30 30 25 20 31 30 30  25 7d 7d 23 6c 6f 67 6f    100% 100%}}#logo
drain           [DEBUG]: 0x000480: 7b 64 69 73 70 6c 61 79  3a 69 6e 6c 69 6e 65 2d    {display:inline-
drain           [DEBUG]: 0x000490: 62 6c 6f 63 6b 3b 68 65  69 67 68 74 3a 35 35 70    block;height:55p
drain           [DEBUG]: 0x0004a0: 78 3b 77 69 64 74 68 3a  31 35 30 70 78 7d 0a 20    x;width:150px}. 
drain           [DEBUG]: 0x0004b0: 20 3c 2f 73 74 79 6c 65  3e 0a 20 20 3c 61 20 68     </style>.  <a h
drain           [DEBUG]: 0x0004c0: 72 65 66 3d 2f 2f 77 77  77 2e 67 6f 6f 67 6c 65    ref=//www.google
drain           [DEBUG]: 0x0004d0: 2e 63 6f 6d 2f 3e 3c 73  70 61 6e 20 69 64 3d 6c    .com/><span id=l
drain           [DEBUG]: 0x0004e0: 6f 67 6f 20 61 72 69 61  2d 6c 61 62 65 6c 3d 47    ogo aria-label=G
drain           [DEBUG]: 0x0004f0: 6f 6f 67 6c 65 3e 3c 2f  73 70 61 6e 3e 3c 2f 61    oogle></span></a
drain           [DEBUG]: 0x000500: 3e 0a 20 20 3c 70 3e 3c  62 3e 34 31 31 2e 3c 2f    >.  <p><b>411.</
drain           [DEBUG]: 0x000510: 62 3e 20 3c 69 6e 73 3e  54 68 61 74 e2 80 99 73    b> <ins>That...s
drain           [DEBUG]: 0x000520: 20 61 6e 20 65 72 72 6f  72 2e 3c 2f 69 6e 73 3e     an error.</ins>
drain           [DEBUG]: 0x000530: 0a 20 20 3c 70 3e 50 4f  53 54 20 72 65 71 75 65    .  <p>POST reque
drain           [DEBUG]: 0x000540: 73 74 73 20 72 65 71 75  69 72 65 20 61 20 3c 63    sts require a <c
drain           [DEBUG]: 0x000550: 6f 64 65 3e 43 6f 6e 74  65 6e 74 2d 6c 65 6e 67    ode>Content-leng
drain           [DEBUG]: 0x000560: 74 68 3c 2f 63 6f 64 65  3e 20 68 65 61 64 65 72    th header
drain [DEBUG]: 0x000570: 2e 20 20 3c 69 6e 73 3e 54 68 61 74 e2 80 99 73 . <ins>That...s
drain [DEBUG]: 0x000580: 20 61 6c 6c 20 77 65 20 6b 6e 6f 77 2e 3c 2f 69 all we know.</i
drain [DEBUG]: 0x000590: 6e 73 3e 0a ns>.

#2 Updated by Leonid Protasov over 6 years ago

I construct request like this:

httpReq(url, {
    method: 'POST'
})

As you see i dont include postdata at all.
To workaround I do:

httpReq(url, {
    postdata: {}
})

#3 Updated by Andreas Smas over 6 years ago

  • Status changed from New to Invalid

I wouldn't call that a "workaround" but rather the real way to do it. Just changing the method doesn't affect the semantics of the request. It just changes what's sent as the HTTP verb. If you want Showtime to act as if it is a POST request for real you need to set postdata (even though it's empty as in this case)

Also available in: Atom PDF