fastcgi++: Client sent unknown content type - fastcgi++

Have written simple server using fastcgi++ 2.1 lib and configured fastscgi in apache2 web server. When I make post request to the server with Content Type: application/json, server throws an internal server error. Have checked apache error.log file and found following log:
[Wed Jan 08 13:56:40 2014] [error] [client 127.0.0.1] FastCGI: server "/var/www/testserver" stderr: "Client sent unknown content type." from "http://abcd.com/testserver" with a POST request method.
When I set Content Type to "application/x-www-form-urlencoded" its working fine and request get served. Please help me on how to serve request with Content Type as "application/json". Is there any configuration required for this to support?

Yeah solved !
In fastcgi++ lib, Content Type "application/x-www-form-urlencoded" is hard-coded. Have changed it to "application/json" and rebuild the fastcgi++ lib. Now I'm able to serve request with Content Type "application/json".

Related

Server responded with 400 Bad Request during HTTP Post request

I am using SIM800 to send HTTP Post request to a remote InfluxDB database. I have successfully sent HTTP Post request to the database from my computer using Curl as shown below.
01:~$ curl -i -XPOST 'http://<ip address>:8086/write?db=mydb' --data-binary 'location,host=server01,region=us-west value=0.99'
HTTP/1.1 204 No Content
Content-Type: application/json
Request-Id: 3c958273-edb2-11eb-88ca-000000000000
X-Influxdb-Build: OSS
X-Influxdb-Version: 1.6.3
X-Request-Id: 3c958273-edb2-11eb-88ca-000000000000
Date: Mon, 26 Jul 2021 01:38:54 GMT
After that when I tried using SIM800, I received 400 Bad Request after executing AT+HTTPACTION=1 . The remote server responded with "+HTTPACTION: 1,400,0" . Below are the AT Commands.
AT+SAPBR=3,1,"CONTYPE","GPRS"
AT+SAPBR=3,1,"APN","myAPN"
AT+SAPBR=1,1
AT+HTTPINIT
AT+HTTPPARA="CID",1
AT+HTTPPARA="URL","http://<ip address>:8086/write?db=mydb"
AT+HTTPPARA="CONTENT","application/json"
AT+HTTPPARA="USERDATA","location,host=server01,region=us-west value=0.55"
AT+HTTPDATA=300,5000
AT+HTTPACTION=1
AT+HTTPREAD
AT+HTTPTERM
AT+SAPBR=0,1
Besides that, i captured the packets when SIM800 sent http post request but could not find the http post body.
The http post body can be seen in the captured packets when sending http post using Curl.
I appreciate if anyone can shed some light on this matter. Thank you in advance.
I managed to get it to work. Here are the AT commands:-
AT+SAPBR=3,1,"CONTYPE","GPRS"
AT+SAPBR=3,1,"APN","myAPN"
AT+SAPBR=1,1
AT+HTTPINIT
AT+HTTPPARA="CID",1
AT+HTTPPARA="URL","http://<ip address>:8086/write?db=mydb"
AT+HTTPPARA="CONTENT","application/json"
AT+HTTPDATA=48,5000
location,host=server01,region=us-west value=0.55
AT+HTTPACTION=1
AT+HTTPREAD
AT+HTTPTERM
AT+SAPBR=0,1
after executing the AT+HTTPDATA, quickly execute the HTTP data (location,host...).

Springboot parsing HTTP HTTPS

I have found such error message in my Springboot app logs:
Oct 20 14:22:14 ip-10-0-78-113 web: 2020-10-20 14:22:14.388 INFO 3802 — [nio-8081-exec-5] o.apache.coyote.http11.Http11Processor : Error parsing HTTP request header
Oct 20 14:22:14 ip-10-0-78-113 web: Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level.
Oct 20 14:22:14 ip-10-0-78-113 web: java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986
...
I got to know, that its probably because somebody / some app is calling my endpoint with use of HTTPS instead of HTTP. I was able to log those requests by including in properties:
logging.level.org.springframework.web: trace
logging.level.org.apache: trace
Now I have received unparsed text, something like this:
Received [ ÷ ó÷=EVq&GŵH¡à}C¶vÓÂíÿ#,¾ )L /ð^ w» e<Ú5~ñ¨7ëÌaÒ*l×e $À/À+À0À,̨̩À ÀÀ
À / 5
localhost ÿ
3 & $ ¬·lä¹]Ö·a6ððòvcd»[7Ûj V - + ]
Is it possible to decode/decrypt it, and find out what the actual API call was?
I had same problem & make it working by using http:// instead of https://

Robot Framework, How to download a file returned in a response body using only request api

I'm using robot framework to send requests without opening a browser. One of the requests is supposed to download a file. But when I send this request the file is not downloaded (even if I have a 200 status code).
${uri} set variable /api/pricing/ExportImportParams/downloadExportParams
Create Session test ${url} cookies=&{cookies}
${resp}= Get Request test ${uri} headers=&{headers}
${resp_code} = Set Variable ${resp.status_code}
${resp_code} = Convert To String ${resp_code}
Run Keyword And Continue On Failure Should be Equal ${resp_code} 200
The test is passed while the status code is 200.
But no file is downloaded
Here is the response Headers
content-disposition: attachment;
filename="Export Site Parameter_2020-01-03_09-21-39.xlsx";
filename*=UTF-8''Export%20Site%20Parameter_2020-01-03_09-21-39.xlsx
content-length: 3767 content-type:
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
date: Fri, 03 Jan 2020 09:21:38 GMT server: Kestrel x-powered-by:
ASP.NET
Thanks for helping
Making an assumption that you are using the RequestsLibrary to perform the HTTP Get request to retrieve the file. Althought the documentation does not specify it, the content attribute of the returned response object contains the data. This can then be easily stored in a file using the standard OperatingSystem library.
*** Settings ***
Library RequestsLibrary
Library OperatingSystem
*** Test Cases ***
File Download Using RequestsLibrary
${file_name} Set Variable file_example_XLS_10.xls
${uri} Set Variable /wp-content/uploads/2017/02/${file_name}
Create Session test https://file-examples.com
${response}= Get Request test ${uri}
Run Keyword And Continue On Failure Should Be Equal As Numbers ${response.status_code} 200
Create Binary File ${EXECDIR}/${file_name} ${response.content}

Laravel & VestaCP: 500 Internal Server Error

Im trying to deploy a Laravel 5.8.* project to my host while using the next template: Laravel web template for VestaCP but I am getting the next error:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at info#iberoseguridad.eu to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
Also, this is the error log from my host:
[Mon Jun 03 19:17:12.497219 2019] [core:error] [pid 22984] [client 68.183.55.192:33376] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: mydomain
Is there any way to fix this error?

"Failed to call HTTP server" error after upgrading SonarQube from 6.0 to 6.7.2

I have upgraded a SonarQube server from 6.0 to 6.7.2. Everything is fine, except that, after logging in as user "admin" and navigating to tab Administration, clicking on subtab System yields an error message
An error has occurred: please contact your administrator.
In file web.log:
2018.03.06 11:38:24 ERROR web[AWH6436/ICo3FeIjAAAz][o.s.s.w.WebServiceEngine] Fail to process request http://<HOST NAME>:20295/sonarqube/api/system/info
java.lang.IllegalStateException: Failed to call HTTP server of process [key='ce', ipcIndex=3, logFilenamePrefix=ce]
at org.sonar.ce.http.CeHttpClientImpl.call(CeHttpClientImpl.java:171)
at org.sonar.ce.http.CeHttpClientImpl.retrieveSystemInfo(CeHttpClientImpl.java:60)
at org.sonar.server.platform.ws.StandaloneSystemInfoWriter.write(StandaloneSystemInfoWriter.java:53)
at org.sonar.server.platform.ws.InfoAction.handle(InfoAction.java:64)
at org.sonar.server.ws.WebServiceEngine.execute(WebServiceEngine.java:103)
at org.sonar.server.ws.WebServiceFilter.doFilter(WebServiceFilter.java:86)
at org.sonar.server.platform.web.MasterServletFilter$GodFilterChain.doFilter(MasterServletFilter.java:126)
...
Caused by: java.io.IOException: Server returned HTTP response code: 503 for URL: http://10.145.61.55
The IP address is that of the server. There is no mention of any port in the error message, I don't know if this has any relation with the error.
It seems that the Web component cannot access the Compute Engine component. However nothing particular was found in file ce.log which ends with a trace Compute Engine is operational.
I followed the short migration guide in https://docs.sonarqube.org/display/SONAR/Upgrading.
Environment: Linux, JDK 8, Oracle DB
Does anyone as a clue? Many thanks in advance.
For whoever who might stumble on the same issue: it was an error in my proxy configuration. Increasing the logging level by setting sonar.log.level=DEBUG in file sonar.properties yielded the following new traces in file web.log:
2018.03.07 11:52:04 DEBUG web[AWIAFTpArQRjrTzMAAAg][s.n.w.p.h.HttpURLConnection] sun.net.www.MessageHeader#668ee27b5 pairs: {GET http://127.0.0.1:40413/systemInfo HTTP/1.1: null}{User-Agent: SonarQube 6.7.2.37468 # AWHmcYEU8aGLjZ5sPfjj Java/1.8.0_60}{Host: 127.0.0.1:40413}{Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2}{Proxy-Connection: keep-alive}
2018.03.07 11:52:04 DEBUG web[AWIAFTpArQRjrTzMAAAg][s.n.w.p.h.HttpURLConnection] sun.net.www.MessageHeader#527214044 pairs: {null: HTTP/1.1 301 Moved Permanently}{Server: BlueCoat-Security-Appliance}{Location: http://10.145.61.55}{Connection: Close}
2018.03.07 11:52:04 DEBUG web[AWIAFTpArQRjrTzMAAAg][s.n.w.p.h.HttpURLConnection] Redirected from http://127.0.0.1:40413/systemInfo to http://10.145.61.55
2018.03.07 11:52:04 ERROR web[AWIAFTpArQRjrTzMAAAg][o.s.s.w.WebServiceEngine] Fail to process request http://<HOST NAME>:20295/sonarqube/api/system/info
The proxy was redirecting the Compute engine URL http://127.0.0.1:40413/systemInfo to http://10.145.61.55.
The solution was to add 127.0.0.1 to http.nonProxyHosts in file sonar.properties.

Resources