Batch request - 400 bad request response - gmail-api

I'm sending the following batch request for getting threads:
POST /batch HTTP/1.1
Host: www.googleapis.com
Accept-Encoding: gzip
User-Agent: Magin (gzip)
Accept-Language: en;q=1, fr;q=0.9, de;q=0.8, zh-Hans;q=0.7, zh-Hant;q=0.6, ja;q=0.5
Content-Type: multipart/mixed; type="application/http"; boundary="737d0154-1999-455c-9886-65d7121a1382"
access_token=accToken&quotaUser=user
--737d0154-1999-455c-9886-65d7121a1382
Content-Type: application/http
Content-ID: <0x8d93fa0>
GET /gmail/v1/users/me/threads/146df2dd11472f07 HTTP/1.1
Host: googleapis.com
Accept-Encoding: gzip
User-Agent: Magin (gzip)
Accept-Language: en;q=1, fr;q=0.9, de;q=0.8, zh-Hans;q=0.7, zh-Hant;q=0.6, ja;q=0.5
--737d0154-1999-455c-9886-65d7121a1382
Content-Type: application/http
Content-ID: <0x8d93190>
GET /gmail/v1/users/me/threads/146df14c9a13b5d9 HTTP/1.1
Host: googleapis.com
Accept-Encoding: gzip
User-Agent: Magin (gzip)
Accept-Language: en;q=1, fr;q=0.9, de;q=0.8, zh-Hans;q=0.7, zh-Hant;q=0.6, ja;q=0.5
--737d0154-1999-455c-9886-65d7121a1382
Content-Type: application/http
Content-ID: <0x8d93190>
GET /gmail/v1/users/me/threads/146def434891a5b0 HTTP/1.1
Host: googleapis.com
Accept-Encoding: gzip
User-Agent: Magin (gzip)
Accept-Language: en;q=1, fr;q=0.9, de;q=0.8, zh-Hans;q=0.7, zh-Hant;q=0.6, ja;q=0.5
--737d0154-1999-455c-9886-65d7121a1382
Content-Type: application/http
Content-ID: <0x8d93190>
GET /gmail/v1/users/me/threads/146def1dbfe6579c HTTP/1.1
Host: googleapis.com
Accept-Encoding: gzip
User-Agent: Magin (gzip)
Accept-Language: en;q=1, fr;q=0.9, de;q=0.8, zh-Hans;q=0.7, zh-Hant;q=0.6, ja;q=0.5
--737d0154-1999-455c-9886-65d7121a1382
Content-Type: application/http
Content-ID: <0x8d93190>
GET /gmail/v1/users/me/threads/146def155ca0ab2b HTTP/1.1
Host: googleapis.com
Accept-Encoding: gzip
User-Agent: Magin (gzip)
Accept-Language: en;q=1, fr;q=0.9, de;q=0.8, zh-Hans;q=0.7, zh-Hant;q=0.6, ja;q=0.5
--737d0154-1999-455c-9886-65d7121a1382--
However I get 400 bad request as a response from the Google servers: Request failed: bad request (400)
Any ideas why this is happening and how I can fix it?
EDIT: interesting behavior: it works if there are <= 3 batched requests but if there are more it doesn't.

two things i notice:
(1) the space before the Content-Type on the first part
(2) missing a final "--737d0154-1999-455c-9886-65d7121a1382--" at the very end of the POST (on it's own line, etc), note the trailing "--" AFTER it the boundary as well...

I had faced the same issue and apparently having \r\n before the nested calls inside the batch request fixed it for me
ex:
--foo_bar
Content-Type: application/http
GET /v1/people:searchContacts?query=query&pageSize=100 HTTP/1.1
--foo_bar
Content-Type: application/http
GET /v1/otherContacts:search?query=a&pageSize=100&readMask=emailAddresses,names HTTP/1.1
--foo_bar
Content-Type: application/http
GET /v1/people:searchDirectoryPeople?query=query&pageSize=100&readMask=emailAddresses,names HTTP/1.1
--foo_bar--
Right before the GET has \r\n and not just \n or \n\n

Related

Login by azure Microsoft something not work on ipad/iphone

I’m working on a website which is deployed kén azure and login through azure microsoft. However, it only works on login website on computer. Whenever I login to the website by some account ( on an ipad or an iphone, it turns to signin-oidc (error 500) and then I cannot access to home page or the other pages . Anybody face to this problem and is there any solution for this? Thanks
Go to my website -> login -> azure microsoft login page open -> login by azure microsoft -> return token from azure microsoft to client -> my website check access this token -> ....
Here is the content of the BeginAuth:
Summary
URL: https://login.microsoftonline.com/common/SAS/BeginAuth
Status: 200 OK
Source: Network
Address: *******
Initiator:
AjaxHandlerControl.js:110
Request
POST /common/SAS/BeginAuth HTTP/1.1
Content-Type: application/json; charset=UTF-8
Accept: application/json
Accept-Language: vi-vn
Accept-Encoding: br, gzip, deflate
Origin: https://login.microsoftonline.com
User-Agent: Mozilla/5.0 (iPad; CPU OS 12_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.2 Mobile/15E148 Safari/604.1
Referer: https://login.microsoftonline.com/
Content-Length: 2220
Connection: keep-alive
Cookie: ESTSAUTH=AQABAAQAAABeAFzDwllzTYGDLh_qYbH8o3IjKkzc2x1r88yy-081xaEhysFzWkgE5Giluas3rg_Dp5-Fw5bh9r4-LSLhpkG14oOyEzrVVAOR4NPQXDA5JIAKdw1Xtan0t4znDHFGqQVix1O2lkm-Y2o1nlDxmM-_swpy5MAxb7yb_b2tA_b2ZMT_MoLndRqejWKdawyYST7h5bMr6ewZNg2ts52SqlXt4BveNWIWrq5mN-xO0D4_SyqC6DPun5N_4wZoyI0I7Zj5qE9qsosdLlqgBiPi_O18QoWqRWhfjJ2B6LoteSlSaF9QgRP409lFoKBDcs5eLguK1uPGPd4X-2AXixn217QIFztBBs-EQzqiJly5xXykGURHG_PUzSaCA2akgGKyD-5QDEIKA8VCniiFHwqoX8EQGdXCUeDjC5AkBk1rxhfeAM06bJ0H-Uz6KWvV5mFNhxwmUwArKSR-QBaN5soW7k63SvO8eF31GP_u2MC4QXjZnXD8YeHclcp3qt4nHGrMJ204p85hj_Lnqj5Aio23f_4WGGJoOUN5RQIrWFP2ua81ww2Cz12xSBGPmSka7F5EeB8LNF_oYx2omVhhFVKZJapnyiuEap_DOyiEntQCsIy6SY8nNyDdkDhYAmjzSS0-uJPYkpO4JCUWq5Z8FN6wrne1hgdN5f-HaHCHPqJw1b73LxWPJMMlOb1TceHvDfDahII99BFhLcGAEZJYE28o2rBopNHNDqOz1PcryTdV4IgNmtYZwq_VtGBKUN60BRuxXbBCfXKb62j9tc4HD2fEfJ7dXLv15Zt-o9hFFeJCKc04419BG9r_yeZ0yMezJv7_8jea-JG3mjyPkVbwEfoD8nSkIAAgAEAA8AEAAA; ESTSAUTHPERSISTENT=AQABAAQAAABeAFzDwllzTYGDLh_qYbH896tJrsebgq-fyKSmZvVkIpkuag5kO86qDT_eS2hkuIxJ6npcaoiZ9um5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lydkgEpjXJzyEyfRACjhZ_vKuEVUEqzKoCErpAbskdeRUTjqrMo70cB4tpzTB4GZFZonBLCTk0Ml3cUT-LLTZuhiu3Y_h4gAA
Host: login.microsoftonline.com
hpgact: 2101
canary: AQABAAAAAABeAFzDwllzTYGDLh_qYbH8a9SO3xGF3g6AWJIZDi54fWSNEiKErEt6YvrvJ3Fm-lIO4Y7kO9-ACPx-kAIHTbn_u5mhreKAsiP-Hn_b2PV7QPvjMYjHNFmOtYhXtFueCuvsxD-V2agrgXRBl82z91-Vv7ketwmG5XCIAJ4RBJBnEHiv2jAc671jIueFntKCDdwcbJ2t-karKLeSSx7VYafv5aDr8MhFDm-03Io8LpfLVSAA
hpgid: 1114
hpgrequestid: aa519c8c-30f9-46dd-95bb-ee6094414d00
client-request-id: 8fa2950c-7b79-400d-ac8c-630c65ec4c48
Response
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Pragma: no-cache
Set-Cookie: fpc=Ah-RTB1jgiFCgCfEhHxEiA42YPZ6AgAAABNet9UOAAAAElWPKAEAAABFXrfVDgAAAA; expires=Wed, 19-Feb-2020 08:39:37 GMT; path=/; secure; HttpOnly
Set-Cookie: x-ms-gateway-slice=prod; path=/; secure; HttpOnly
Set-Cookie: stsservicecookie=ests; path=/; secure; HttpOnly; SameSite=None
Expires: -1
Cache-Control: no-cache, no-store
Date: Mon, 20 Jan 2020 08:39:36 GMT
Content-Length: 2356
X-Content-Type-Options: nosniff
P3P: CP="DSP CUR OTPi IND OTRi ONL FIN"
x-ms-ests-server: 2.1.9898.20 - SIN1 ProdSlices
x-ms-request-id: 0c407fdc-ec18-4822-9d91-d3c662525100
Strict-Transport-Security: max-age=31536000; includeSubDomains
client-request-id: 8fa2950c-7b79-400d-ac8c-630c65ec4c48
Request Data
MIME Type: application/json
Encoding: UTF-8
Request Data:
Here is the content of the EndAuth:
Summary
URL: https://login.microsoftonline.com/common/SAS/EndAuth
Status: 200 OK
Source: Network
Address: *****
Initiator:
AjaxHandlerControl.js:110
Request
POST /common/SAS/EndAuth HTTP/1.1
Content-Type: application/json; charset=UTF-8
Accept: application/json
Accept-Language: vi-vn
Accept-Encoding: br, gzip, deflate
Origin: https://login.microsoftonline.com
User-Agent: Mozilla/5.0 (iPad; CPU OS 12_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.2 Mobile/15E148 Safari/604.1
Referer: https://login.microsoftonline.com/
Content-Length: 2249
Connection: keep-alive
Cookie: clrc={%2218281%22%3a[%22k+8Er6ui%22%2c%22MGmgPvDz%22%2c%22zHWAEBZj%22]}; fpc=AqGp0xmfg8lLgos3zMYZv1E2YPZ6AQAAAD9nt9UOAAAAElWPKAEAAABzZ7fVDgAAAA; stsservicecookie=ests; x-ms-gateway-slice=prod; ESTSAUTH=AQABAAQAAABeAFzDwllzTYGDLh_qYbH8PFcC4jCAPANOfMbq-YWj9-5u5ZM2Hz4lOtVb4th1FHqBtfAlPxYXbkTjGWbI0eqbYK3yBdWUzJaf_pjfuAqipUpJKfo388tRwdsTr9CtHJCsb2Bb-gj7weggZrS9qDlSiQ5yPiNdbpi1Q3eeed7T6rOIPDkM2JzgwuQPRTy1A7OElUbdPfqV1-y03NT-Oad5niK4qIyLO3qbUiXXSWAHPvW4Qucn9u5all3U2DEgJN5oDLwy58GOvgcl3m1N6XtwA8Ty67IybRFIWQD86VrNJwoTV9PD6mXBm7LI0ITaa9a6_3V2jBkVTIgVK8BTQUPdQs5SDFD_M9ER8mLbd99HRVlw_aB0rPB_wyML3EDDtStBbbm2PpLF7-Bc9LHmNdXhVTrtUlob46GTiSput6771BBKXJ1O7fVHv85aLIHoCq31FQwDxO8CxoRa-RK1AECnEVckc8FXVUzOEpr4AzIlB85f82AyKGX0TwmssksASFUd7gCiRNVVRQCgmORCqZgW-juZjLKFBPMbS9DnavYyxTmhzNKkHSy-9cIXFfEpCXlUXyYVJSoLBvKpFY9yWaz6-G1G86YiuLIjYzJQTHv0tgq403dHQ49M10FiOPpgrt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d1sqLyFIo52qI1ICYVz0_3ozkcTDV1vemApeSunFPxJEyWbLhKWIIMiRSwgAA; brcap=1; esctx=AQABAAAAAABeAFzDwllzTYGDLh_qYbH8C_SETJvY2bJWBn6b4YBwYZ7oWTYtAHOB03Kf6w7z6vx4agejzLR-KrengZwkpZuVxa46rpVJHyjKDFiK21Ze093B5qYDaOrkz3uZPgiJdYqVbjuCum0RxKS6CmtEx7u5UHUmbF28DhO-fw7SE8GiQOgk-WMKtZ5l15V323DZ2yAgAA
Host: login.microsoftonline.com
hpgact: 2101
canary: AQABAAAAAABeAFzDwllzTYGDLh_qYbH8B01oIe03wUWEzPISTHAYY9DIzppZsJdHlAJVTT_qDkwW63QTbVzZyGyuWTH8DI13YW7IQFYQyNSmc82iyDqXYnIYXKzNwTXHaKFvgefiHsMs4s_H-iKu7nbw5riTkXpshEv8RqrNzUCQ5RzPkN_DmRrl6pxzpx5PE9xy_lbhsMNJhlRHR9ydR32alGrgIUMk5jeiWnXwyn-Iv0ZeaTm_liAA
hpgid: 1114
hpgrequestid: 6046baec-30dd-4d4d-b4c0-c2a9bdd65000
client-request-id: 907865da-9681-4d95-a65a-dd40a3661f79
Response
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Pragma: no-cache
Set-Cookie: fpc=AqGp0xmfg8lLgos3zMYZv1E2YPZ6AQAAAD9nt9UOAAAAElWPKAEAAABzZ7fVDgAAAA; expires=Wed, 19-Feb-2020 09:19:24 GMT; path=/; secure; HttpOnly
Set-Cookie: x-ms-gateway-slice=prod; path=/; secure; HttpOnly
Set-Cookie: stsservicecookie=ests; path=/; secure; HttpOnly; SameSite=None
Expires: -1
Cache-Control: no-cache, no-store
Date: Mon, 20 Jan 2020 09:19:23 GMT
Content-Length: 2356
X-Content-Type-Options: nosniff
P3P: CP="DSP CUR OTPi IND OTRi ONL FIN"
x-ms-ests-server: 2.1.9898.20 - SIN1 ProdSlices
x-ms-request-id: be26f84b-5386-4b04-a31f-64f06db04e00
Strict-Transport-Security: max-age=31536000; includeSubDomains
client-request-id: 907865da-9681-4d95-a65a-dd40a3661f79
Request Data
MIME Type: application/json
Encoding: UTF-8
Request Data:
Here is the content of the failed signin-oidc content:
Summary
URL: https://*****/signin-oidc
Status: 500 Internal Server Error
Source: Network
Address: *****
Request
POST /signin-oidc HTTP/1.1
Cookie: ARRAffinity=b67cf4989142f516cf1224c1da63f82fb954c6d5a9d7f17d287740c0647a1f76
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Content-Type: application/x-www-form-urlencoded
Origin: https://login.microsoftonline.com
Content-Length: 1886
Accept-Language: vi-vn
Host: *******
User-Agent: Mozilla/5.0 (iPad; CPU OS 12_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.2 Mobile/15E148 Safari/604.1
Referer: https://login.microsoftonline.com/kmsi
Accept-Encoding: br, gzip, deflate
Connection: keep-alive
Response
HTTP/1.1 500 Internal Server Error
Pragma: no-cache
Content-Type: text/html; charset=utf-8
Expires: -1
Date: Mon, 20 Jan 2020 08:23:38 GMT
Transfer-Encoding: Identity
Cache-Control: no-cache
Access-Control-Allow-Origin: *
X-Powered-By: ASP.NET
Strict-Transport-Security: max-age=2592000
Server: Kestrel
Request Data
MIME Type: application/x-www-form-urlencoded
id_token: eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6InBpVmxsb1FEU01LeGgxbTJ5Z3FHU1ZkZ0ZwQSJ9.eyJhdWQiOiJjNjA4ZjhhYi1lZjA4LTRjYjEtYjAzMy1hNzQyMjg0ODA3NmEiLCJpc3MiOiJodHRwczovL2xvZ2luLm1pY3Jvc29mdG9ubGluZS5jb20vMWZkMWRmYzQtZTVlMy00ZDM3LWFkZGItM2VjYTQxMWVjYWVjL3YyLjAiLCJpYXQiOjE1Nzk1MDgyOTMsIm5iZiI6MTU3OTUwODI5MywiZXhwIjoxNTc5NTEyMTkzLCJhaW8iOiJBV1FBbS84T0FBQUFSUWhkY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hutNkjRYYA9J-dr_EWgqMxJ32ez0tMZ1rrPWWnow1tT8M7sqGJspDcOU08NK2Hhg12jGCXAuI8biXhycBguS-EZgJnh2pYPq7SE8Fin-XaF17rJDxNXCEp-B1Rw8sTVbNLo-cdaTf0tqKE01Ey2srTrQA3-5Y5EgsQnZ-PuhzykvglYxeBbV09e2wZ7Cw0AngaZBwTYrs-3ETv8sakZwXTX2gFjUy5q61MCxpdhHepRvd2lT7ZEAWNXGrzBBVoM-VM0C-Lztf65ZqNhP_0U8vgwHsxvzA47KWEGbdMLC80xoGNLO1p8zU3n9Yzkdp0fsc5z7ExBTVAexe6WBoALObVNPSWBOhR0BEdRFgkyPfWJBYBbQTqwv-C6CwBojTOI4e4GPGZfmJXvlKQg
session_state: 7f9db494-e7d2-4803-b8ec-979d0dad856f
Return this page and can't go anything page on my website

How to send post request to REST API CakePHP 3.6

Backend CakePHP 3.6 REST , frontend React
Request
Request URL: http://localhost/restcake/v1/posts.json
Request Method: POST
Status Code: 400 Bad Request
Remote Address: [::1]:80
Referrer Policy: no-referrer-when-downgrade
Reponse
code: 400
file: “PATHTO\vendor\cakephp\cakephp\src\Controller\Component\SecurityComponent.php”
line: 351
message: “’_Token’ was not found in request data.”
url: “/v1/translations.json”
Request header
Accept: application/json
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9,mn-MN;q=0.8,mn;q=0.7
Cache-Control: no-cache
Connection: keep-alive
Content-Length: 68
Content-Type: application/json
Cookie: csrfToken=1ca4d0479b6721049b17fa879e269816515cdd216e2f0a85a828dad33fa2bacf3a341f74b7d08b75ffa3b9fbebd0219914d50d30e6abeec45129c2fe39e1f7fa; CAKEPHP=pv2nkumt1a32urftf2jvq5nrrm; remember_me=Q2FrZQ%3D%3D.ZGYyNDNiMjdkOTRlNDMyZGVjYzhkMWUwZTE4MTJhOWJjZjBkZjEzODA5MWE2ZjJkOWRhN2RkNTg0ZjEwZDM4ML2ESQrHcOqYaNiMcRSYoK4WcuCAPx%2Fz7UgmA6cBU6pZXYnQX29kT2zUhGDCVlU%2F0ZPjlHtX7qiyIsuEwiCrmBonaNBD6G8QL4WMgap2QOieQ6KV%2BnQjRKz%2FYvzyuxwcia7ChJNdcvy1%2B9UzCSSLWX%2BDBR%2F1Qivlvc0Dl1HL6tX%2BaWWc6IfoT82wS331XCMUzcIo0yQzyVp595PkT%2F8NjXtyK3M%2BeB5bKy%2FMYCAIrXLJWVCse9NYACix35fST0unQ69FBxihlu0Wli%2BAT3NGQWo%3D
Host: localhost
Origin: http://localhost:4000
Pragma: no-cache
Referer: http://localhost:4000/
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.92 Safari/537.36
I temporary disabled CORS in middleware.

Yeoman,Grunt, AngularJS 404 cannot Post /

I have this little angular app on the frontend which is a food list. So write a food and click submit and it will show the list.
When I add a food I query my backend wich is a sails app at localhost:1337 and it gets updated. The problem is I get redirected to
localhost:9000/#/food and get 404.
This is the faulty request
POST / HTTP/1.1
Host: localhost:9000
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image /webp,*/*;q=0.8
Accept-Encoding: gzip, deflate
Accept-Language: fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4
Content-Type: application/x-www-form-urlencoded
Cookie:sails.sid=s%3A8gIjNxaZVE9dMr7nonXJzEaQ9hUcvcHm.Sp0K6ezep%2F7Y%2BV6TivtdRxqiBV 2S1LdH2IDNPWS9Ikk
Origin: http://localhost:9000
Referer: http://localhost:9000/
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36
X-DevTools-Emulate-Network-Conditions-Client-Id: 137B2031-138E-4B6B-A3AE- FB8EE96E9015
HTTP/1.1 404 Not Found
Connection: keep-alive
content-length: 14
Content-Type: text/html; charset=utf-8
Date: Mon, 23 Feb 2015 12:21:51 GMT
X-Content-Type-Options: nosniff
The other request that gets code 200 and update the server model looks like this:
OPTIONS /food HTTP/1.1
Host: localhost:1337
Accept: */*
Accept-Encoding: gzip, deflate, sdch
Accept-Language: fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4
Access-Control-Request-Headers: accept, content-type
Access-Control-Request-Method: POST
Origin: http://localhost:9000
Referer: http://localhost:9000/
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36
X-DevTools-Emulate-Network-Conditions-Client-Id: 137B2031-138E-4B6B-A3AE- FB8EE96E9015
HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: content-type, access-control-allow-origin, authorization,X-Requested-With
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS, HEAD
Access-Control-Allow-Origin: http://localhost:9000
Allow: GET,POST,PUT,HEAD,DELETE,TRACE,COPY,LOCK,MKCOL,MOVE,PURGE,PROPFIND,PROPPATCH, UNLOCK,REPORT,MKACTIVITY,CHECKOUT,MERGE,M- SEARCH,NOTIFY,SUBSCRIBE,UNSUBSCRIBE,PATCH,SEARCH,CONNECT
Connection: keep-alive
Content-Length: 175
Content-Type: text/html; charset=utf-8
Date: Mon, 23 Feb 2015 12:21:51 GMT
set-cookie: sails.sid=s%3A_kBdyRZgZ23Gh9YLkZfWBgnMody- jq-S.IY71%2BhJiBxTd19YIG2tgS2EOn1LPT%2BD9QAEQWtVB%2FbE; Path=/; HttpOnly
X-Powered-By: Sails <sailsjs.org>
At first I was looking at sails but I have CORS enabled and everything just like this:
https://github.com/tarlepp/angular-sailsjs-boilerplate/blob/master/backend/config/cors.js
So maybe it's more an angular issue. The request that fails is from the frontend to itself so just a redirect on itself when it has been updated on the server. I don't get why the request is denied...
If you want to take a look at the code:
http://okamuuu.hatenablog.com/entry/2014/04/10/135240
Issues seem the same as this Yeoman, Grunt, AngularJS and error 404 on POST form but that doesn't help me
Well, apparently your request is going to the port 9000:
Host: localhost:9000
Yet you said your app is running at port 1337.
So, in your $http requests, you need to specify the port. Otherwise, it will use the port your browser is currently connected to (9000) and there's no app there!
So, instead of
$http.get('/someUrl')
Try
$http.get('http://localhost:1337/someUrl')

Browsers Not Receiving From Server

I'm writing a simple webserver and right now I'm just trying to set up a generic
response to see that it's working. Right now, it's only been working on Firefox and not
on Chrome or Opera. Below are some of the requests I've gotten and a generic response is at the end. Is there a line I'm missing in the response? Is there really a generic response to get the server up and running?
I see that the requests have "Connection: keep-alive", so I tried leaving the connection open for a few seconds, and that didn't seem to help. I tried sending the data separately from the response header and that didn't really help either.
GET / HTTP/1.1
Host: 192.168.1.128
Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.43 Safari/537.31
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
GET / HTTP/1.1
User-Agent: Opera/9.80 (X11; Linux x86_64) Presto/2.12.388 Version/12.15
Host: 192.168.1.128
Accept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/webp, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1
Accept-Language: en-US,en;q=0.9
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
GET / HTTP/1.1
Host: 192.168.1.128
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:11.0) Gecko/20100101 Firefox/11.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Response here:
HTTP/1.0 200 OK
Date: Sun Apr 14 15:13:36 2013
Server: server_th
Content-Type: text/html
Content-Length: 40
Connection: close
<html><body><h3>Hey!</h3></body></html>
Your response has no body, so you will see a blank page. Besides, it seems to be lacking the trailing CRLF, but I am not sure whether it is due to copy-paste.
Check the HTTP specs.
EDIT: in the updated response, body length is actually 39, although it is declared 40. could it be that the client is waiting for remaining payload?

Why doesn't chrome cache google app engine blobstore

I'm using blobstore to serve audio files embedded in HTML5 audio element. Because I have a blobkey as a part of url I can assume that for any given url its content will never change. That looks like a perfect setup for caching.
Yesterday I implemented a solution which seemed to work. At least I remember that it worked ;). Unfortunately today I discovered, that it doesn't work with Chrome and production server. It works perfectly with Internet Explorer and Firefox. It even works with Chrome and development server - I use version 1.7.6. My solution uses Cache-Control headers, but it seems that only Firefox makes any use of it. Additionally I added an ETag header. When I discover If-None-Match request header with the same value I return 304 code. That seems to work with Internet Explorer. It also works with Chrome and development server. I remember that it had worked yesterday with Chrome and production, but I'm not completely sure. Anyway the problem I have is why both caching mechanisms are ignored by Chrome. I suspect that it may have something to do with chunked encoding which is generated only for chrome, but I don't understand why caching is disabled in that case
And now a lot of details.
Firefox
Initial request headers:
Host: eduzabawy.appspot.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0
Accept: audio/webm,audio/ogg,audio/wav,audio/*;q=0.9,application/ogg;q=0.7,video/*;q=0.6,*/*;q=0.5
Accept-Language: pl,en-us;q=0.7,en;q=0.3
Range: bytes=0-
Referer: http://eduzabawy.appspot.com/dziecko/
Cookie: children="jEDor1B8VRDRJreWmUVlUQ\075\075"; session=eyJfc2lkIjoiWk91QmlsOEJlTEd4QVFuYVFiYkpsTyJ9|1365190508|81d81772f6f409dd57ad43a9f447f92d1b56d29e
Connection: keep-alive
Initial response headers:
HTTP/1.1 206 Partial Content
Cache-Control: public max-age=100000000
Content-Range: bytes 0-37249/37250
Content-Type: audio/ogg
Date: Fri, 05 Apr 2013 19:45:47 GMT
Etag: blobstore
Server: Google Frontend
X-Firefox-Spdy: 3
On subsequent loads it seems that Firefox doesn't even try to fetch the files. This is how I thought it should work.
Internet Explorer
Initial request headers:
Accept: */*
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
Referer: http://eduzabawy.appspot.com/dziecko/
Accept-Language: pl-PL
Accept-Encoding: gzip, deflate
Host: eduzabawy.appspot.com
Connection: Keep-Alive
Cookie: children="WyzUQwHEzwX6qnjfn21KEw\075\075"; session=eyJfc2lkIjoia2VOd0llR0hvRHU1cUN0cE1QSWRpWCJ9|1365192921|f2279f82b21947c4d064dbf44a5ce9e1bd95cc0d
Initial response headers:
HTTP/1.1 200 OK
Cache-Control: public max-age=100000000
ETag: blobstore
Content-Type: audio/mpeg
Date: Fri, 05 Apr 2013 20:15:23 GMT
Server: Google Frontend
Content-Length: 4637
Subsequent request headers:
Accept: */*
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
Referer: http://eduzabawy.appspot.com/dziecko/
Accept-Language: pl-PL
Accept-Encoding: gzip, deflate
Host: eduzabawy.appspot.com
If-None-Match: blobstore
Connection: Keep-Alive
Cookie: children="WyzUQwHEzwX6qnjfn21KEw\075\075"; session=eyJfc2lkIjoia2VOd0llR0hvRHU1cUN0cE1QSWRpWCJ9|1365192921|f2279f82b21947c4d064dbf44a5ce9e1bd95cc0d
Subsequent response headers:
HTTP/1.1 304 Not Modified
ETag: blobstore
Content-Type: audio/mpeg
Content-Length: 4637
Chrome + development server
Initial request headers:
Host: localhost:8080
Connection: keep-alive
Accept-Encoding: identity;q=1, *;q=0
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.43 Safari/537.31
Accept: */*
Referer: http://localhost:8080/dziecko/
Accept-Language: pl-PL,pl;q=0.8,en-US;q=0.6,en;q=0.4
Accept-Charset: ISO-8859-2,utf-8;q=0.7,*;q=0.3
Cookie: children="xYNsqzfdtZ-2Z764lFSzk1Ed8-g1QoNlcaexsD79gSY\075"; session=eyJfc2lkIjoiTE9CZDc0SHJENHF4OWJua1J4S3dTQSJ9|1365192253|37815772acab0bf44a0c501ea0fd0dc7c617dd09
Range: bytes=0-
Initial response headers:
HTTP/1.1 206 Partial Content
etag: blobstore
cache-control: public max-age=100000000
content-type: audio/mpeg
Content-Range: bytes 0-4636/4637
Content-Length: 4637
Server: Development/2.0
Date: Fri, 05 Apr 2013 20:32:19 GMT
Subsequent request headers:
Host: localhost:8080
Connection: keep-alive
Accept-Encoding: identity;q=1, *;q=0
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.43 Safari/537.31
Accept: */*
Referer: http://localhost:8080/dziecko/
Accept-Language: pl-PL,pl;q=0.8,en-US;q=0.6,en;q=0.4
Accept-Charset: ISO-8859-2,utf-8;q=0.7,*;q=0.3
Cookie: children="xYNsqzfdtZ-2Z764lFSzk1Ed8-g1QoNlcaexsD79gSY\075"; session=eyJfc2lkIjoiTE9CZDc0SHJENHF4OWJua1J4S3dTQSJ9|1365192253|37815772acab0bf44a0c501ea0fd0dc7c617dd09
Range: bytes=0-4636
If-None-Match: blobstore
Subsequent response headers:
HTTP/1.1 304 Not Modified
Content-Type: text/html
Server: Development/2.0
Date: Fri, 05 Apr 2013 20:33:08 GMT
Chrome + production server
Initial request headers:
Host: eduzabawy.appspot.com
Connection: keep-alive
Accept-Encoding: identity;q=1, *;q=0
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.43 Safari/537.31
Accept: */*
Referer: http://eduzabawy.appspot.com/dziecko/
Accept-Language: pl-PL,pl;q=0.8,en-US;q=0.6,en;q=0.4
Accept-Charset: ISO-8859-2,utf-8;q=0.7,*;q=0.3
Cookie: children="sU9aqnqEf67eZFpS7BKSMw\075\075"; session=eyJfc2lkIjoieFlGWlJLMnRwSHJuOVFCb1haTnJLUCJ9|1365194193|2a13cd9eb7aceeb40c43bd82a763d893436d9f1f
Range: bytes=0-
Initial response headers:
HTTP/1.1 206 Partial Content
Cache-Control: public max-age=100000000
ETag: blobstore
Content-Type: audio/mpeg
Content-Range: bytes 0-4636/4637
Date: Fri, 05 Apr 2013 20:36:35 GMT
Server: Google Frontend
Transfer-Encoding: chunked
Subsequent requests and responses are the same as initial.
Your max-age seems too long and going over 3 years... I read from somewhere the maximum you should set in GAE is no more than 1 year.
Anyway, there's one more header you should try to set (Pragma: Public), which worked for me (I'm caching image from blobstore though, here's a few lines from my source code):
httpResponse.Header().Set("Cache-Control", "public, max-age=600")
httpResponse.Header().Set("Pragma", "Public")
blobstore.Send(httpResponse, project.ImageBlobKey)
By the way the above also cause Google to delivery your file from the edge cache, which really speed static resources up a lot!

Resources