I am facing an error when a user enters search string as '%' in url itself. After entering my url looks as
http://localhost:3000/search/%
Now its showing "NetworkError: 400 Bad Request - http://localhost:3000/search/%". I want to redirect to some other page and show, a bad request image when the error occurs. Please suggest me some ideas to do this.
I have attached the error image.
UPDATE
I have tried the below.
config/application.rb:
config.exceptions_app = self.routes
config/routes.rb:
match "/400", :to => "errors#bad_request"
It's not coming inside the bad_request method.
In Log i am getting error as
Invalid request: Invalid HTTP format, parsing fails.
Have you checkout this gem 'utf8-cleaner' which removes invalid UTF-8 characters from the environment so that your app doesn't choke on them.
If you want custom error pages: then look at this answer
Related
I have some network code which behaves differently if an error is due to timeout, bad url, url not found etc, etc. which are all covered by NSURLErrorDomain.
However if I get a http error, such as http 406, then that's not in NSURLErrorDomain. The domain is "HTTP Error", but I don't want to use that as a hardcoded string, I want to use whatever its NSWhateverErrorDomain definition is, but after loads of searching I just can't find what that is anywhere.
Undocumented NSURLErrorDomain error codes (-1001, -1003 and -1004) using StoreKit
Reference:
https://developer.apple.com/reference/cfnetwork/cfnetworkerrors
I am new to Rails and Nginx. I was asked to add custom error pages to our app. I found instructions to do so on this site and my custom error pages render just fine locally. When I go to the url /no_such_page, I see the appropriate page. When I deploy the code to our test server running nginx and try the same url, I see the following instead:
500 Internal Server Error
If you are the administrator of this website, then please read this web application's log file and/or the web server's log file to find out what went wrong.`
On the nginx server, if I go to the url \404, then I do see my page, so I know it renders ok.
Both my local machine and the server are running under the development environment.
I've added this to config\development.rb:
config.consider_all_requests_local = false
config.exceptions_app = self.routes
Here is what I've added to routes.rb:
%w(404 500).each do |code|
get code, to: "errors#show", :code => code, :via => :all
end
and my errors_controller looks like this:
class ErrorsController < ApplicationController
def show
status_code = params[:code] || 500
render status_code.to_s
end
end
Does anyone know if there is something special that I need to do in my nginx config to make this work?
500 Internal Server Error If you are the administrator of this website, then please read this web application's log file and/or the web server's log file to find out what went wrong.
This error message is from Rails itself, not from Nginx.
https://github.com/rails/rails/blob/v5.0.0.1/actionpack/lib/action_dispatch/middleware/show_exceptions.rb#L15-L22
It means that your custom error page is itself raising an exception, which would lead to an infinite loop of error->show error page->error->show error page->... Rails detects this and halts with the error message you are seeing. Check your logs for this string to see what the error is:
Error during failsafe response:
I have a COLDFUSION page which except parameters from url and show them in fields. My url looks like this which is working.
http://www.example.com/test.cfm?activeUrl=www.msn.com&secure=False
But following is not working. I have added http before www in activeUrl value.
http://www.example.com/test.cfm?activeUrl=httpwww.msn.com&secure=False
It is giving me following error. "ERRROR STATUS: URL contains outer http"
Can any one help me to solve this problem?
For me, It seems that something related to iis configuration.
The string in httpwww.msn.com is causing your browser error. It should be http://www.msn.com, but should also be URL encoded.
ohh, i have not checked the application.cfc ONREQUESTSTART method. it has some condition for query string, which is showing this error. :(
At the second call to Client.ProcessUserAuthorization(); after I get the code from the oauth server, I get an exception: Error occurred while sending a direct message or getting the response.
Here is the last part from the log file taken with log4net, the full log is recorded in this gist: https://gist.github.com/tonyeung/5513769
2013-05-03 15:14:41,292 (GMT-5) [10] DEBUG DotNetOpenAuth.Messaging.Channel - Sending AccessTokenAuthorizationCodeRequestC request.
2013-05-03 15:14:41,393 (GMT-5) [10] DEBUG DotNetOpenAuth.Http - HTTP POST http://localhost:38828/OAuth/Token
2013-05-03 15:14:41,450 (GMT-5) [10] ERROR DotNetOpenAuth.Http - http://localhost:38828/OAuth/Token returned 400 BadRequest: Bad Request
2013-05-03 15:14:41,450 (GMT-5) [10] DEBUG DotNetOpenAuth.Http - WebException from http://localhost:38828/OAuth/Token:
{"error":"invalid_request"}
I've uploaded the solution to https://github.com/tonyeung/dotnetopenauth
The entry point is in the about action on the home controller of the Client project.
The solution is in VS2012, the latest nuget dnoa package. Nuget restore is on.
Please note that I'm implementing pieces as I need them in order to understand how the library works. I'm sure that this error is due to a missing implementation somewhere, but I'm not sure what it is?
So it looks like I was missing implementations for IsAuthorizationValid and CreateAccessToken in the Authorization Server. Please check the github repository for the stubs i put in that makes the error go away.
EDIT:
There was also a database validation error that I didn't trap. So basically any error on the server side will cause this message it looks like.
EDIT2:
There was also an issue where if the url of the page contains any non url encoded values it will throw an invalid request. In my case, my login page had a querystring parameter of returnUrl, and I had set it to /Home, which it DID NOT like, had to be: %2FHome
I have the following lines in my Rails controller code
url_parsed = URI.parse(url)
response = Net::HTTP.get_response(url_parsed)
When I passed www.google.com as url, it gave
undefined method `request_uri' for #<URI::Generic:0x00000002e07908 URL:www.google.com>
on the second line, even though I don't call the method request_uri anywhere.
In this case, I'd like it to show my nice error page, instead of this ugly error. How can I do it?
your url string is missing a protocol: url="http://www.google.com"
Then your code will return Net::HTTPOK - see this documentation