wso2 am gateway forwarding of multipart/form-data post requests - multipartform-data

I am using a demo API which receives a file and note as multipart/form-data input and displays the content of the file and the note. Here is a sample HTML which runs the API correctly:
<html>
<body>
<FORM action="http://cgi-lib.berkeley.edu/ex/fup.cgi" method="post">
<P>Choose file: <INPUT type="file" name="upfile">
<p>Note: <INPUT type="text" name="note">
<p><INPUT type="submit" value="Send">
</FORM>
</body>
</html>
Now I'm trying to created a managed API in the WSO2 APIM publisher. Below are the parameters I filled in:
I'm replacing the action of the HTML to go through the API I added:
<FORM action="http://ec2-52-48-93-41.eu-west-1.compute.amazonaws.com:8280/test" method="post">
But now when I run the HTML I get the following error from the API:
cgi-lib.pl: Unknown Content-type: application/x-www-form-urlencoded; charset=UTF-8
Seems like the WSO2 gateway forwarded the request as application/x-www-form-urlencoded rather than as mulipart/form-data.
Based on the following discussion multipart form data file upload using WSO2 API manger ? I tried to comment out
<messageFormatter contentType="multipart/form-data"
class="org.apache.axis2.transport.http.MultipartFormDataFormatter"/>
<messageBuilder contentType="multipart/form-data"
class="org.apache.axis2.builder.MultipartFormDataBuilder"/>
And replace them with
<messageFormatter contentType="multipart/form-data"
class="org.wso2.carbon.relay.ExpandingMessageFormatter"/>
<messageBuilder contentType="multipart/form-data"
class="org.wso2.carbon.relay.BinaryRelayBuilder"/>
Then restarted the server, but it did not cause any impact.
Any ideas will be appreciated.
Some log messages that I collected. The target API is different, but it is also a multipart/form-data API which dumps whatever it receives.
The incoming request does have content-type multipart/form-data, with content-length of 292
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 >> POST /test/1.0.0 HTTP/1.1 {org.apache.synapse.transport.http.headers}
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 >> Host: ec2-52-48-93-41.eu-west-1.compute.amazonaws.com:8280 {org.apache.synapse.transport.http.headers}
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 >> Connection: keep-alive {org.apache.synapse.transport.http.headers}
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 >> Content-Length: 292 {org.apache.synapse.transport.http.headers}
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 >> Cache-Control: max-age=0 {org.apache.synapse.transport.http.headers}
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 >> Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 {org.apache.synapse.transport.http.headers}
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 >> Origin: null {org.apache.synapse.transport.http.headers}
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 >> Upgrade-Insecure-Requests: 1 {org.apache.synapse.transport.http.headers}
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 >> User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36 {org.apache.synapse.transport.http.headers}
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 >> Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryqwBdAwOnlDYeHNNR {org.apache.synapse.transport.http.headers}
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 >> Accept-Encoding: gzip, deflate {org.apache.synapse.transport.http.headers}
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 >> Accept-Language: en-US,en;q=0.8,he;q=0.6 {org.apache.synapse.transport.http.headers}
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 >> Cookie: region3_registry_menu=visible; region1_manage_menu=visible; region1_identity_menu=visible; menuPanel=visible; menuPanelType=main; csrftoken=n1g69f3slt1d90qvtaa28rtm1b {org.apache.synapse.transport.http.headers}
The outgoing request does not have content-type:
DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 >> POST /sample2/api/company/upload HTTP/1.1 {org.apache.synapse.transport.http.headers}
DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 >> Cookie: region3_registry_menu=visible; region1_manage_menu=visible; region1_identity_menu=visible; menuPanel=visible; menuPanelType=main; csrftoken=n1g69f3slt1d90qvtaa28rtm1b {org.apache.synapse.transport.http.headers}
DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 >> Origin: null {org.apache.synapse.transport.http.headers}
DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 >> Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 {org.apache.synapse.transport.http.headers}
DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 >> Cache-Control: max-age=0 {org.apache.synapse.transport.http.headers}
DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 >> Upgrade-Insecure-Requests: 1 {org.apache.synapse.transport.http.headers}
DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 >> Accept-Encoding: gzip, deflate {org.apache.synapse.transport.http.headers}
DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 >> Accept-Language: en-US,en;q=0.8,he;q=0.6 {org.apache.synapse.transport.http.headers}
DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 >> Transfer-Encoding: chunked {org.apache.synapse.transport.http.headers}
DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 >> Host: localhost:8080 {org.apache.synapse.transport.http.headers}
DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 >> Connection: Keep-Alive {org.apache.synapse.transport.http.headers}
DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 >> User-Agent: Synapse-PT-HttpComponents-NIO {org.apache.synapse.transport.http.headers}
Naturally, the incoming response has HTTP 415, unsupported media:
DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 << HTTP/1.1 415 Unsupported Media Type {org.apache.synapse.transport.http.headers}
DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 << Server: Apache-Coyote/1.1 {org.apache.synapse.transport.http.headers}
DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 << Content-Length: 0 {org.apache.synapse.transport.http.headers}
DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 << Date: Mon, 28 Mar 2016 13:53:05 GMT {org.apache.synapse.transport.http.headers}
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 << HTTP/1.1 415 Unsupported Media Type {org.apache.synapse.transport.http.headers}
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 << Access-Control-Allow-Origin: * {org.apache.synapse.transport.http.headers}
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 << Access-Control-Allow-Methods: POST {org.apache.synapse.transport.http.headers}
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 << Access-Control-Allow-Headers: authorization,Access-Control-Allow-Origin,Content-Type {org.apache.synapse.transport.http.headers}
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 << Date: Mon, 28 Mar 2016 13:53:05 GMT {org.apache.synapse.transport.http.headers}
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 << Transfer-Encoding: chunked {org.apache.synapse.transport.http.headers}
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 << Connection: keep-alive {org.apache.synapse.transport.http.headers}
Also worth loading is the synapse of the API:
<?xml version="1.0" encoding="UTF-8"?>
<api xmlns="http://ws.apache.org/ns/synapse"
name="admin--test"
context="/test/1.0.0"
version="1.0.0"
version-type="context">
<resource methods="POST" url-mapping="/*" faultSequence="fault">
<inSequence>
<filter source="$ctx:AM_KEY_TYPE" regex="PRODUCTION">
<then>
<property name="api.ut.backendRequestTime"
expression="get-property('SYSTEM_TIME')"/>
<send>
<endpoint name="admin--test_APIproductionEndpoint_0">
<http uri-template="http://localhost:8080/sample2/api/company/upload"/>
</endpoint>
</send>
</then>
<else>
<sequence key="_sandbox_key_error_"/>
</else>
</filter>
</inSequence>
<outSequence>
<class name="org.wso2.carbon.apimgt.usage.publisher.APIMgtResponseHandler"/>
<send/>
</outSequence>
</resource>
<handlers>
<handler class="org.wso2.carbon.apimgt.gateway.handlers.security.CORSRequestHandler">
<property name="apiImplementationType" value="ENDPOINT"/>
</handler>
<handler class="org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler"/>
<handler class="org.wso2.carbon.apimgt.gateway.handlers.throttling.APIThrottleHandler">
<property name="policyKey" value="gov:/apimgt/applicationdata/tiers.xml"/>
<property name="policyKeyApplication"
value="gov:/apimgt/applicationdata/app-tiers.xml"/>
<property name="policyKey" value="gov:/apimgt/applicationdata/tiers.xml"/>
<property name="policyKeyApplication"
value="gov:/apimgt/applicationdata/app-tiers.xml"/>
<property name="id" value="A"/>
<property name="policyKeyResource"
value="gov:/apimgt/applicationdata/res-tiers.xml"/>
</handler>
<handler class="org.wso2.carbon.apimgt.usage.publisher.APIMgtUsageHandler"/>
<handler class="org.wso2.carbon.apimgt.usage.publisher.APIMgtGoogleAnalyticsTrackingHandler">
<property name="configKey" value="gov:/apimgt/statistics/ga-config.xml"/>
</handler>
<handler class="org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler"/>
</handlers>
</api>

By Default it looks like newer API Manager doesn't preserver certain headers from the clients.You need to add following property http.headers.preserve = Content-Type in repository/conf/passthru-http.properties inorder to preserve the Content-Type header.

Just to stress Ajanthan answer, in order to preserve the headers correctly, the correct change would be to add the following to passthru-http.properties
http.headers.preserve=Content-Length,Content-Type
It's a new feature of ESB 4.9.0, so not much documented, but you can read about it in this blog: http://prabu-lk.blogspot.co.il/2015/09/how-to-preserving-http-headers-in-wso2.html

Related

React Axios is returning error 500, Laravel BE + Apache, no issue on direct API call via PostMan

There are a lot of issues like this, but I don't see any resolutions.
I had a VPS.
I set up my React build files on public_html root.
I have my Laravel setup on the same folder: public_html/casino/server/public
I am using Axios to process the request to Laravel endpoints.
PHP-FPM 7.4
Apache 2.4
Laravel 5.8
This is the Request Header:
POST /casino/server/public/sysman/login HTTP/1.1
Accept: application/json, text/plain, */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Connection: keep-alive
Content-Length: 154
Content-Type: application/json;charset=UTF-8
Cookie: CookieInfoScript=1
Host: ***.com
Origin: https://***.com
Referer: https://***.com/login
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36
sec-ch-ua: "Google Chrome";v="105", "Not)A;Brand";v="8", "Chromium";v="105"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Windows"
The Response Header: (as you can see content-length is 0)
HTTP/1.1 500 Internal Server Error
Date: Mon, 05 Sep 2022 02:50:18 GMT
Server: Apache
Access-Control-Allow-Origin: https://***.com
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: POST, GET, OPTIONS, DELETE, PUT
Access-Control-Allow-Headers: x-xsrf-token, x-requested-with, Content-Type, origin, authorization, accept, client-security-token
Access-Control-Expose-Headers: Content-Security-Policy, Location
Access-Control-Max-Age: 600
Content-Type: text/html; charset=UTF-8
Content-Length: 0
Connection: close
To add GET Requests are being processed just fine.
I can also process the login request via Postman.
But of some reasons, not when coming from the React App.
No errors on BE, everything is running as expected.
Banging my head on this one for a few days already.
Can't seem to figure it all out.
Not much action on htaccess side.
The root online contains redirect to /login page.
Laravel public htaccess only contains the usual laravel stuff.
Apache Error Log:
[Sun Sep 04 22:50:18.527744 2022] [proxy_fcgi:error] [pid 21267:tid 47190394283776] [client 103.177.208.118:58353] malformed header from script 'index.php': Bad header: \x1f\x8b\b, referer: https://***.com/login [Sun Sep 04 22:50:18.527836 2022] [proxy_fcgi:error] [pid 21267:tid 47190394283776] [client 103.177.208.118:58353] AH01070: Error parsing script headers, referer: https://***.com/login [Sun Sep 04 22:50:18.527858 2022] [proxy_fcgi:error] [pid 21267:tid 47190394283776] (22)Invalid argument: [client 103.177.208.118:58353] AH01075: Error dispatching request to : , referer: https://***.com/login
Lastly, when running php artisan optimize, I am seeing Content type being outputted on console, can this be the issue?
[

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_4WGGJoOUN5RQIrWFP2ua81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; buid=AQABAAEAAABeAFzDwllzTYGDLh_qYbH84TKiKjYi6BuVyBpssR3qZD2fNIWjWH4IUGj1tgV1CjBekKsQGEtqYNmdMRIXd7N8BOo9vpLQC07NWlPoRa1jUH_-ayS6xTMT9xGQjDEZ1UggAA; fpc=Ah-RTB1jgiFCgCfEhHxEiA42YPZ6AgAAABNet9UOAAAAElWPKAEAAABFXrfVDgAAAA; stsservicecookie=ests; x-ms-gateway-slice=prod; clrc={%2218281%22%3a[%22MGmgPvDz%22%2c%22k+8Er6ui%22]}; brcap=1; esctx=AQABAAAAAABeAFzDwllzTYGDLh_qYbH8LpxpIlSUEu2HI0fzE_V_IRZe2RNJp-f2QqQ5Q3Ier3lWomWnATFbyAXP5tkq-U9ruARvMs7F-zosSlydkgEpjXJzyEyfRACjhZ_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-Oad5niK4qI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oraFryHLRKuKIwSwT_0-q0B2Wbz2eA0-uVeQoT9QRycHAIi4uWMbpSlQIoOh8uDQ4XWkKxC1qIPGH5ph6yZGr6DBs9zw8F52_ABHjQtjZeqLwOH_2tJwhHlhRjseQQ-sfPqs2unGfEqH_ea1HcT6ghJkMwKbyWw5FgO_HtElrYNn9BIQt04jPBBupWH57uw-GdKlnyk1_iUFhTIG8In4g6nfoyAAIABAAEABAAA; ch=2ZexXvpi5pBsPVR3WldndSN3Jss01W9lqt3Oo4atPto; ESTSAUTHLIGHT=+ccbda084-3cfd-4fba-a121-64822022264b; ESTSSC=00; buid=AQABAAEAAABeAFzDwllzTYGDLh_qYbH83h0-hsSMC7dM5dkdMfsldYZQhtZ_5IMn2ZWccmkXmkyQugUDrd1sqLyFIo52qI1ICYVz0_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
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oiMHdQNEIyUWhpa081WEJHYkxoRkxBQSIsInZlciI6IjIuMCJ9.MO2h7kO8I9ANFI9TgJZCVGpl0J7oxmeMQPMKM1Vt8AzXqLxN46CS1q4QlAR8x8Ca_D8IPpB277HpumUVc4vseffBJ9i_M_6I4Qqt2bzmHCcIRqTGluc8C-UlEBFvIBshOILCjVpS6feESboRTbWkIgVPfArlb03FtvS1HDinaWpAWRMPSNr40sYvF_3I7VT4wk52Ne1ZZRIhB71wAbeYzlcBlXQJA8yZhg2oGuoBy3B0V45v8f9Kskd7wIgvq0rI-kxSTKIo7pxHclNnvjDJm4J4DeAdA5dzKdmaCTzN4EMDsOZY0y1vM3UdJnM1BQkHip3FyRQ1Hj6eolbPwafdaQ
state: CfDJ8H2WPQdBhutNkjRYYA9J-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

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')

Batch request - 400 bad request response

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

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?

Resources