bad-request

How do I fix a HTTP Error 400: Bad Request?

北城余情 提交于 2019-12-23 02:32:37
问题 I am trying to web scrape, here is my code. For some reason I am getting HTTP Error 400: Bad Request, I have never had this before. Any ideas? Here is my code: import urllib.request import re url = ('https://www.myvue.com/whats-on') req = urllib.request.Request(url, headers={'User Agent': 'Mozilla/5.0'}) def main(): html_page = urllib.request.urlopen(req).read() content=html_page.decode(errors='ignore', encoding='utf-8') headings = re.findall('<th scope="col" abbr="(.*?)">', content) print

Firefox “Bad request” caused by corrupt google tracking cookie

喜夏-厌秋 提交于 2019-12-22 18:16:02
问题 We have an issue on our site whereby some Firefox users are receiving a "Bad Request" message when they visit our site (nothing else, just the words "Bad Request"!) This would appear to be due to a corrupt google tracking cookie, possibly __utmz (one person delete the google cookies in turn and once that one was removed the site came back to life.) Our website uses this Javascript google tracking code: var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");

Tomcat is not redirecting to 400 bad request custom error page

删除回忆录丶 提交于 2019-12-22 08:53:38
问题 We have tomcat 9 web server in production. The problem we are facing is we want to show the custom error page for our application if tomcat receives any malformed URL as follows http://URL/| or http://URL/[ I have added error page tag in web.xml of tomcat application server as follows <error-page> <error-code>400</error-code> <location>/error.html</location> </error-page> <error-page> <error-code>404</error-code> <location>/error.html</location> </error-page> and we have error.html in our

AOP @Around: return BAD_REQUEST response

半城伤御伤魂 提交于 2019-12-22 08:41:39
问题 In a Spring rest application, every single URL must start with an application id (appId). This appId must be validated in every single rest service. Instead of duplicating code, I tried to create an @Aspect with an @Around advice. This is correctly executed before any rest method. However, if the application id is unknown, I do not want neither to create a stack trace or neither to return a 200 (response OK). Instead I do want to return a BAD_REQUEST response code. If I throw an exception in

MVC Controller return a bad request?

寵の児 提交于 2019-12-22 01:23:11
问题 I was wondering if it was possible to return a bad request with content from an MVC Controller? The only way I have been able to do this is to throw HttpException however here I can't set any content. Tried this approach to but for some odd reason I am always getting an OK back. Is it possible to do this? public class SomeController : Controller { [HttpPost] public async Task<HttpResponseMessage> Foo() { var response = new HttpResponseMessage(HttpStatusCode.BadRequest); response.Content = new

How can I customize HTTP 400 responses for parse errors?

做~自己de王妃 提交于 2019-12-21 15:16:12
问题 I've written a REST API service that requires that all responses be JSON. However, when the Go HTTP request parser encounters an error, it returns 400 as a plain text response without ever calling my handlers. Example: > curl -i -H 'Authorization: Basic hi there' 'http://localhost:8080/test' -v * Trying ::1... * TCP_NODELAY set * Connected to localhost (::1) port 8080 (#0) > GET /test HTTP/1.1 > Host: localhost:8080 > User-Agent: curl/7.54.0 > Accept: */* > Authorization: Basic hi > there > <

How can I customize HTTP 400 responses for parse errors?

倾然丶 夕夏残阳落幕 提交于 2019-12-21 15:15:25
问题 I've written a REST API service that requires that all responses be JSON. However, when the Go HTTP request parser encounters an error, it returns 400 as a plain text response without ever calling my handlers. Example: > curl -i -H 'Authorization: Basic hi there' 'http://localhost:8080/test' -v * Trying ::1... * TCP_NODELAY set * Connected to localhost (::1) port 8080 (#0) > GET /test HTTP/1.1 > Host: localhost:8080 > User-Agent: curl/7.54.0 > Accept: */* > Authorization: Basic hi > there > <

PHP Bad Request in Curl on SOAP interface of http://www.cyberlogic.gr/webservices/PlaceSearch

孤者浪人 提交于 2019-12-20 06:23:52
问题 I am trying to call the url using curl in php. I get a BAD REQUEST error . if someone can help me,I do not get what the problem is Their "recipe" is as follows: http://wl.filos.com.gr/services/WebService.asmx?op=PlaceSearch (look at soap 1.1) The code I have is: <? // xml data $soap_request = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; $soap_request .= "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http:/

MS Azure - Bad Request 400

徘徊边缘 提交于 2019-12-20 05:53:01
问题 I keep getting a bad request error every time I run this line of code: List<Account> accounts = await App.accountTable.Where(account => account.EmailAddress == email).ToListAsync(); Here is the error message: A first chance exception of type 'Microsoft.WindowsAzure.MobileServices.MobileServiceInvalidOperationException' occurred in mscorlib.dll Microsoft.WindowsAzure.MobileServices.MobileServiceInvalidOperationException: The request could not be completed. (Bad Request) at Microsoft

ASP.NET MVC: How to handle 400 bad request error when url end with %

孤者浪人 提交于 2019-12-19 21:46:23
问题 I am trying to handle all HTTP errors to my custom error pages, but I find that when there is a % at the end of url, i cannot use config setting or code to handle it, for example: http://localhost/abc% the response is: Bad Request - Invalid URL HTTP Error 400. The request URL is invalid. So, can we use config setting or c# code to handle this error request? 回答1: See this 4 part series for configuring custom error pages within IIS: http://www.dotnetscraps.com/dotnetscraps/post/Did-you-know