w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
How to set the HTTP status code on a filter?
class FooController < ApplicationController before_filter :foo_filter def action respond_to :html end private def foo_filter head :gone unless some_conditions end end

Categories : Ruby On Rails

How to get casper.js http.status code?
How about this (from the Docs): var casper = require("casper").create({ }), utils = require('utils'), http = require('http'), fs = require('fs'); casper.start(); casper.thenOpen('http://www.yahoo.com/', function(response) { casper.capture('test.png'); utils.dump(response.status); if (response == undefined || response.status >= 400) this.echo("failed"); }); casper.on('http.status.404', function(resource) { this.echo('wait, this url is 404: ' + resource.url); }); casper.run(function() { casper.exit(); });

Categories : Javascript

C# Selenium WebDriver: Get HTTP Status Code
Not without an external tool no. You see, this has been brought up a number of times in the past and is one of the largest "issues" within Selenium's official issue tracker. The particular issue has been bounced around and essentially decided that it's outside the scope of Selenium. This however, does not mean that it is not possible. Thankfully, you are using C#, so it's a little easier than you may think. Recently, one of the Selenium developers wrote a blog post outlining exactly how to do this in C#. It is a three part blog post to help explain each step and uses an external tool, called Fiddler (which, by the way, is one awesome tool). Fiddler is a proxy and has a C# API that allows you to intercept requests. It therefore means you can simply "point" Selenium to use that proxy, a

Categories : C#

HTTP Status code for generic failure
If it's server error then it should be 500. If it's client error, use 400. It's hard to be more precise than that without seeing the URI and what you do with it. For example, if "Product no longer available" is a result of GET request, then it should be 404 (not found). But if it was a POST request, then it should be 200 or 202. For the other two, they might not be error. It could be the client has sent the correct request but the stock has been consumed by someone else, in this case server should return 409 (conflict) . If the request was for too much stock from the start, then it should just be 200/202. If you had to have only one code, just use 400 and 200 (see above).

Categories : Http

Detect HTTP 301 status code from JavaScript
You can use $.ajax with jquery It has everything you need here : http://api.jquery.com/jQuery.ajax/ If you look at "statusCode" explaination, you will see you can make something for every code

Categories : Javascript

How to use HTTP status code symbols in RSpec?
On the one hand, response is built with methods like: success? redirect? unprocessable? full list do: response.methods.grep(/?/) On the other hand, Rspec predicates transforms every foo? method to a be_foo matcher. Not sure you can have the 201 this way unfortunately, but creating a custom matcher is quite easy. Note Rails test only rely on a few statuses.

Categories : Ruby On Rails

Accessing http status code constants
Http status codes are maintained by the Internet Assigned Numbers Authority (IANA), whereas readyState is specific to XmlHttpRequest. Therefore just go to a reputable source. The wikipedia article should suffice as this is not really a contentious topic - or, as commented, the official list can be found here You could also wrap those you are interested in into a javascript object var HttpCodes = { success : 200, notFound : 404 // etc } usage could then be if(response == HttpCodes.success){...}

Categories : Javascript

How do I get the HTTP response status code in AngularJS 1.2
I had faced the similar problem.I looked into the angular lib and added a few lines to have status returned in the response itself.In this file,find where promise is being returned. Replace code block starting with var promise = $http(httpConfig).then(function(response) with the following var promise = $http(httpConfig).then(function(response) { var data = response.data, promise = value.$promise; if (data) { // Need to convert action.isArray to boolean in case it is undefined // jshint -W018 if ( angular.isArray(data) !== (!!action.isArray) ) { throw $resourceMinErr('badcfg', 'Error in resource configuration. Expected ' + 'response to contain an {0} but got an {1}',

Categories : Angularjs

HTTP Status 500 customise through webapp error page
The reason for not working is because the webapp has implemented ExceptionMapper that catches the exception instead of letting the custom error page to be resolved from web.xml The resolution would be to remove the ExceptionMapper impl class.

Categories : Misc

How to send HTTP 500 status code in SOAP message
I have to send SOAP message to server, it has to bee a message with code 500 This doesn't make sense. The status code is sent by the server in response to the client's request. If the server sends a 200 OK, your request was correctly formatted and processed.

Categories : C#

How to get http header status code in webview on android?
I posted an answer here that used a simple HTTP request to check the status. If status = 200 GOOD! Load remote URL to webview, else load local HTML page from assets.

Categories : Android

HTTP Status code for content unavailable without a redirect
It sounds like the 4XX series of responses are appropriate here. From the RFC: The 4xx class of status code is intended for cases in which the client seems to have erred. Except when responding to a HEAD request, the server SHOULD include an entity containing an explanation of the error situation, and whether it is a temporary or permanent condition. With this in mind, I think 403 forbidden is the most appropriate: 10.4.4 403 Forbidden The server understood the request, but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated. If the request method was not HEAD and the server wishes to make public why the request has not been fulfilled, it SHOULD describe the reason for the refusal in the entit

Categories : HTML

HTTP Status Code for incompatible columns in a reporting API
The 409 Conflict implies a conflict with the current state of the resource. There is no such conflict, so that's not right. 422 Unprocessable Entity looks more correct. I would also argue that 400 Bad Request would not be unreasonable.

Categories : Api

HTTP Status code for when client is outside the allowed IP subnet
403 Forbidden seems like the most descriptive status code for this. However, RFC 2616 suggests that you could also use 404 Not Found if you don't want to let the user know that the reason for the failure is an access control restriction. It says: If ... the server wishes to make public why the request has not been fulfilled, it SHOULD describe the reason for the refusal in the entity. If the server does not wish to make this information available to the client, the status code 404 (Not Found) can be used instead. If the person attempting the access believes the error code, it might discourage them from trying to find a way around the restriction (e.g. by searching for a proxy). But it probably won't stop a determined hacker.

Categories : PHP

HTTP status code - function called mapping
Code failure is not linked to a single HTTP status code, as there are multiple possible status codes that lead to errors. I could be wrong on this part, but I think that, if the readyState never changes to 4, an abort gets thrown and calls error without returning an HTTP status call at all. I found a useful resource on HTTP status codes and AJAX here.

Categories : Jquery

Getting HTTP status code from a jQueryui Autocomplete call
You'll want to define the source option and perform the submission yourself using $.ajax. Then handle the status codes you care about using the statusCode option: $( "#site_search" ).autocomplete({ source: function(request, response) { $.ajax({ url: '/members/search/suggest', dataType: "json", data: { term: request.term }, success: function(data, textStatus, jqXHR) { response(data); }, error: function(jqXHR, textStatus, errorThrown) { // Handle errors here }, statusCode: { 401: function () { // Disable autocomplete here } } }); });, Note: You will need jquery 1.5+ for this to work.

Categories : Jquery

Bulk checking http status codes without downloading the page
Use the following cURL options to make a HEAD request: CURLOPT_HEADER => true, CURLOPT_NOBODY => true, CURLOPT_CUSTOMREQUEST => 'HEAD', You could also use: CURLOPT_FAILONERROR => true, To have curl_exec return false whenever a erroneous HTTP code is returned. If you have 10,000 URLs and this is a recurring task, you will probably want to look at curl_multi_* functions and process the URLs in batches of 4, 8 or something close to it. The speed-up is significant.

Categories : PHP

can't run form.html page with tomcat container - 404 HTTP Status?
Maybe you can do it by configuring a context. It is discouraged but you can try to add the following in your conf/server.xml just to give a try: <Context path="Beer-v1" docBase="webapps/Beer-v1" crossContext="true" debug="0" reloadable="false"> </Context> EDIT As David Levesque wrote in his answer, there are some incorrect characters in your web.xml (the ” issue seems to be fixed there) and your html file. About this point, I am not sure the servlet names with blanks such as Ch3 Beer are legal (but once again it shouldn't make a problem form your HTML page). Please note also that your servlet-name values are inconsistent. They should be the same in order to link the class and the url mapping. I have made a test with your new web.xml file and without modifying the c

Categories : Tomcat

REST HTTP status code for "success, and thus you no longer have access"
Very interesting question :-) This is why I love REST, sometimes it might get you crazy. Reading w3 http status code definitions I would choose (this of course is just my humble opinion) one of those: 202 Accepted - since this mean "well yes I got your request, I will process it but come back later and see what happens" - and when the user comes back later she'll get a 403(which should be expected behavior) 205 Reset Content - "Yep, I understood you want to remove yourself please make a new request, when you come back you'll get 403" On the other hand (just popped-up in my mind), why should you introduce a separate logic and differentiate that case and not using 200 ? Is this rest going to be used from some client application that has an UI? And the user of the rest should show a pop-u

Categories : Http

POST an invalid object: What HTTP STATUS Code do I have to return?
Generally, you will use 4xx HTTP Status Code when you can manage an exception. Otherwise, you will generate a 5xx HTTP Status Code. For your example, you can use the 400 Bad Request HTTP Status code. 10.4.1 400 Bad Request The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications. From W3C

Categories : C#

HTTP Status 500 - An exception occurred processing JSP page /trail.jsp at line 16
the file in webapps/doc/ will not be in the same context as trail.jsp. You can not include a jsp from another context. Although according to the code you are trying to include a static file. If this is right please update your description.

Categories : Java

Remove query strings from HTTP response status code 301 url redirections
As stated at the mod_alias doc If the client requests http://example.com/service/foo.txt, it will be told to access http://foo2.example.com/service/foo.txt instead. This includes requests with GET parameters, such as http://example.com/service/foo.pl?q=23&a=42, it will be redirected to http://foo2.example.com/service/foo.pl?q=23&a=42 You can change your Redirec 301 to Rewrite rules: Instead of: Redirect 301 /old-site/tees~1-c/blue~123-p.html test.mydomain.com/tees~1-c/blue~123-p.html Redirect 301 /old-site/tees~1-c.html test.mydomain.com/tees~1-c.html Redirect 301 /old-site/content/about.html test.mydomain.com/content/about.html Use: RewriteRule /old-site/tees~1-c.html test.mydomain.com/tees~1-c.html [L,R=301] RewriteRule /old-site/tees~1-c.html test.mydomain.com

Categories : Apache

An attempt to retrieve content from returned the HTTP status code 502. Please check the URL and try again
Twilo evangelist here. So Web API determines how to serialize the data returned from an endpoint (JSON, XML, etc) by looking at the Accept header in the incoming request. It will also set the Content-Type header based on the format of data it returns. The problem is that Twilio's web hook requests don't include an Accept header, and if there is no Accept header Web API defaults to returning JSON. Twilio expects TwiML (our XML-based language) in response to to its request, so if your Web API endpoint is returning JSON Twilio and setting the Content-Type header in the response to application/json, Twilio says thats bad. There are a couple different ways you can tell Web API to format the response as XML. The first is to remove the JSON formatter as an option available to Web API. Th

Categories : Asp Net Mvc

spring form validation: HTTP Status 500 - An exception occurred processing JSP page
First thing to notice: java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'command' available as request attribute This exception means that you haven't specified or specified incorrect model attribute. I've already commented that modelattribute="Candidate" should be modelAttribute="Candidate". Exception is saying that it can not find command object, because it is default one. So you haven't declared your model attribute at all. Also you have to have a class for e.g. Candidate. Which probably you do. public class Candidate { private String name; //getters and setters } Then in your controller create a method: @Controller public class CandidateController { @ModelAttribute("Candidate") public Candidate getCandidate() { retu

Categories : Java

Spring MVC - HTTP status code 400 (Bad Request) for missing field which is defined as being not required
I came across the same situation, and this happens when your parameter is present in the request with an empty value. That is, if your POST body contains "number=" (with empty value), then Spring throws this exception. However, if the parameter is not present at all in the request, it should work without any errors.

Categories : Spring

Differentiate between failed(no network) and cancelled request in ajax error(HTTP status code 0)
I think there is not a straightforward solution but there is a workaround. On http status code 0 you can check... if(navigator.onLine) which will return whether there is some network connected or not.

Categories : Javascript

The request failed with HTTP status 400: Bad Request ( The data is invalid. ): Code base Works on one machine but not another
It's an Internet Proxy issue. The suspect machine had be configured to manually use a proxy server. Turning this off: Control Panel -> Internet Options -> Connections Tab -> Lan Settings Button, and enabling "Automatically detect settings" has fixed the problem.

Categories : Asp Net

Why can't I get my site to recognize a default error page for status code 404 in a WebMatrix WebPages environment?
The customErrors entry in your web.config under system.web works for urls with file extensions as we have established. but to work for extension-less urls, you need to override IIS by adding an entry to the system.webServer node in your web.config: <system.webServer> <httpErrors existingResponse="Replace" errorMode="Custom"> <remove statusCode="404" subStatusCode="-1" /> <error statusCode="404" prefixLanguageFilePath="" path="/Error404.cshtml" responseMode="ExecuteURL" /> </httpErrors> </system.webServer> Having done this, you also need to move any other custom error handling to the system.webServer section and remove the customErrors entry under system.web.

Categories : Asp Net

getting java.io.IOException: HTTP request failed, HTTP status: 404 in ksoap2 while passing xml data to soap1.2 android
Try the below PropertyInfo req = new PropertyInfo(); req.name="silent"; req.type=String.class; req.setValue("<silent>" +"<action>"+logon+"</action>" +"<gameid>"+mygameid+"</gameid>" +"<gpassword>"+mypwd+"</gpassword>" +"<data>" +"<username>"+test@test.com+"</username>" +"<password>"+test+"</password>" +"</data>" +"</silent>"); request.addProperty(req);

Categories : Android

HTTP status 401, but expected data in HTTP response
I don't think the entity could theoretically be the data that would be sent to an authorized request. From RFC 2616: If the 401 response contains the same challenge as the prior response, and the user agent has already attempted authentication at least once, then the user SHOULD be presented the entity that was given in the response, since that entity might include relevant diagnostic information. So it's legal to present entity to a unauthenticated user. As you said, authorized data should not be returned to a client... but in your case, the entities are just both the same for authenticated and unauthenticated users. On the other hand, Google's login page uses 200 as the response code for failing to authenticate. Note that: the response MUST include a WWW-Authenticate hea

Categories : Http

Is HTTP status code 426 Upgrade Required only meant signal an upgrade to a secure channel is required?
Quoting one of my previous answers: HTTP Upgrade is used to indicate a preference or requirement to switch to a different version of HTTP or to another protocol, if possible: The Upgrade general-header allows the client to specify what additional communication protocols it supports and would like to use if the server finds it appropriate to switch protocols. The server MUST use the Upgrade header field within a 101 (Switching Protocols) response to indicate which protocol(s) are being switched. Upgrade = "Upgrade" ":" 1#product For example, Upgrade: HTTP/2.0, SHTTP/1.3, IRC/6.9, RTA/x11 The Upgrade header field is intended to provide a simple mechanism for transition from HTTP/1.1 to some other, incompatible protocol. According to the IANA regist

Categories : Http

Axis2 : Http status 500
Your version of jettison.jar is wrong. Try use the 1.1 version. See this bug for more information: https://wso2.org/jira/browse/CARBON-14352

Categories : Java

Handle HTTP status 500
You should see the actual response from your remote side. Most probably you'll see some boilerplate HTML saying your resource wasn't found, you are not authorized, or something similar instead of the actual WS response. This can happen when the WS server is hidden behind an Apache front end, which is misconfigured to assume you are a browser.

Categories : Java

get the HTTP status server
You could do the following HttpGet httpRequest = new HttpGet(myUri); HttpEntity httpEntity = null; HttpClient httpclient = new DefaultHttpClient(); HttpResponse response = httpclient.execute(httpRequest); response.getStatusLine().getStatusCode()

Categories : Android

Why can't I see my site, and get HTTP Status 404?
I see below points here, which needs to be fixed: Once you deploy your application in tomcat webapp directory, the URL should be something like http://localhost:8080/<web-app-name>/<your servlet> Alternatively you could add a welcome page and check if it is working. For that you need to add welcome page setting in web-xml. See This post for a clue. If this is not working, please share your tomcat directory tree with your war deployed; and the war file directory structure Note: you should be able to expand your war using a zip utility.

Categories : Java

Can someone please tell me why I am getting HTTP Status 406 from Spring
Do you have Jackson/Jackson2 libs on your classpath? If not Spring will create no message converters. From the docs: MappingJackson2HttpMessageConverter (or MappingJacksonHttpMessageConverter) converts to/from JSON — added if Jackson 2 (or Jackson) is present on the classpath.

Categories : Json

HTTP Status for "already logged in"
I think your API could get away with returning the exact same status code / message as it would if it were a successful first login. Here's why... The way I see it, you have two different scenarios from the perspective of the API: new login and re-login. programmatically there is a difference. But, from the perspective of the API consumer, all the consumer wants to know is if login was successful, which it was.

Categories : Http

Spring 3 HTTP Status 404
Acdcjunior is rigth in his comment: Try making, in web.xml: <servlet-mapping> <servlet-name>appServlet</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> instead of *.do. You asked: Besides, why the url is: localhost:8080/hxj/ instead of: localhost:8080/hxj/home.jsp (or /home.do)? I expect that the right URL is: localhost:8080/hxj/home (localhost:8080/hxj/ works only because the welcome URL mapping in the web.XML) That is because that is the request mapping you specified for the controller method. It is not *.jsp because in Spring you use the url to specify which controller method should be invoked, but not the jsp directly. (And it is not *.do because this is not struts)

Categories : Eclipse

HTTP Status 404 error in the jsp, netbeans
No, what you are doing is wrong. I guess you want to submit this form to a Servlet(test.java). First you have to make sure that test.java (btw this is not a proper convention in java for a class name, it should start with an uppercase letter) is actually a servlet by extending the HttpServlet class, and implementing the required methods (doGet() and/or doPost() ...). More Info Here Then you have to map this Servlet in the web.xml. <servlet> <servlet-name>Test</servlet-name> <servlet-class>test.java</servlet-class> </servlet> <servlet-mapping> <servlet-name>Test</servlet-name> <url-pattern>/Test</url-pattern> </servlet-mapping> And then submit the form to the url-pattern of the servlet assigned ab

Categories : Jsp

HTTP Status 0 from AngularJS Get for JSON
In your code, the status assignment only occurs when the error happens. You should be able to get the status when the call was made successfully like this: success(function(data, status, headers, config) { $scope.objects = data; $scope.status1 = status; }).error(function(data, status) { $scope.status1 = status; });

Categories : Json



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.