w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
difference between request header cache policy and response header
I don't think that Cache-Control is wrong and it seems that your content is already cached. From the request headers, I understand that the first request was done at Tue, 20 Aug 2013 13:08:13 GMT as the browser indicates the server "hey, has the content changed since that time?". In return, the server responses with 304 Not Modified header, indicating that the content has not been changed and it should be cached 604800 seconds more until revalidating it. Remember that the caching is done on server side. So, you may want to look at your server defitinitons on js files. Usually, in the deployment environment, I instruct my webserver to send cache header for *.js *.png etc. After configuring the web server for sending cache headers, it is the browser's work to take care of the rest. In that c

Categories : Http

In node.js, how do I get the Content-Length header in response to http.get()?
Not every server will send content-length headers. For example: http.get('http://www.google.com', function(res) { console.log(res.headers['content-length']); // undefined }); But if you request SO: http.get('http://stackoverflow.com/', function(res) { console.log(res.headers['content-length']); // 1192916 }); You are correctly pulling that header from the response, google just doesn't send it on their homepage (they use chunked encoding instead).

Categories : Javascript

How do I clone custom HTTP Request Header Variables to the Response in IIS6?
MSDN has a good write up on working with HTTP header variables in IIS6. HOWTO: Retrieve Request Headers using ISAPI, ASP, and ASP.Net

Categories : Http

make request and response available in scope node js
When are you calling defaultStrings? If you are calling it directly from your routes i.e. by using app.get("some_url", defaultStrings), then req and res should be available to you. EDIT: It appears that you were calling it by: content = strings.defaultStrings(); inside of your index function. In order to pass on the req and res arguments you must simply change your call to content = strings.defaultStrings(req,res,cb), where cb is the callback defined by index.

Categories : Node Js

How, in Node.js, to respond to a GET request from client (send some HTML in response)?
As @Daniel stated in his comment, the response object is certainly an Express object, and you can return your HTML simply by rendering a view, like so: exports.friends = function(request, response) { //do stuff response.render('friends.html'); }; Of course, you would have to define your views in your app.js setup, with something like this: app.set('views', __dirname + '/views')

Categories : Ajax

Node async stream piping
0.10 revamped the Streams API and added the following change in behavior: WARNING: If you never add a 'data' event handler, or call resume(), then it'll sit in a paused state forever and never emit 'end'. So, in 0.10, the stream will wait for a valid listener, like a pipe, or a forced resume without an explicit pause. Steams in 0.8 and older, on the other hand, will start sending 'data' immediately unless instructed to pause. And, in this case, that creates a race condition between the timeout and the stream -- the stream may run in part or even to completion before the timeout expires.

Categories : Node Js

Node.js on Windows, piping multiple scripts
What I would do is use Node.js Transform streams for your scripts, and use combine.js to require and pipe those streams, based on command line arguments. Example: // stream1.js var Transform = require('stream').Transform; var stream1 = new Transform(); stream1._transform = function(chunk, encoding, done) { this.push(chunk.toString() + 's1 '); done(); }; module.exports = stream1; // stream2.js var Transform = require('stream').Transform; var stream2 = new Transform(); stream2._transform = function(chunk, encoding, done) { this.push(chunk.toString() + 's2 '); done(); }; module.exports = stream2; // combine.js var stream1 = require('./' + process.argv[2]); var stream2 = require('./' + process.argv[3]); process.stdin.pipe(stream1).pipe(stream2).pipe(process.stdout); That

Categories : Windows

Mikeal's NodeJS Request modify body before piping
You probably want to use a transform stream. After some googling I found the following blog post.

Categories : Node Js

How to display restful request and response on the browser. My client wants to debug the request and response from client application
There are plenty of browser plugins that'll let you construct a request to RESTful services. My favorite is Postman for Chrome It'll let you type in the URI, required headers, and body, and displayes the results. Very useful for debugging RESTFul services.

Categories : Java

ServiceStack: use attribute in DTO to set response header and response body
A simpler/tidier way to achieve what you want would be to return a HttpResult and define the headers within. public object Get(Todos request) { long count; var items = _repository.GetAll(request.Query, request.Sort, request.IsDesc, request.Limit, request.Offset, out count); var response = items.Select(Mapper.Map<TodoItem, Todo>).ToList(); return new HttpResult(response, HttpStatusCode.OK) { Headers = { {"X-Total-Rows", count} } }; } This avoids polluting your response object with metadata

Categories : Angularjs

OS X cocoa send HTTP response to PHP page, wait for PHP response to request, Continue
In fact you can use the NSMutableURLRequest, if you want to make a test to start you can do this: //test.h #import <Foundation/Foundation.h> @interface test : NSObject<NSURLConnectionDataDelegate>{ NSMutableData* _responseData; } //test.m @implementation test //Just call this method to start the request. -(void)testRequest{ //set request NSURL url = [NSURL URLWithString:@"http://ip/file.php"]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLCacheStorageNotAllowed timeoutInterval:20.0]; //Start the request NSURLConnection * connection; connection = [[NSURLConnection alloc] initWithRequest: request delegate:self]; } after this you have to imp

Categories : Objective C

paypal 400 bad request error getting at WebResponse response = request.GetResponse();
Please change Your CSHTML url as below:- <script type="text/javascript"> function GetGmailContacts() { window.location = "https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize?client_id=clientid&response_type=code+id_token&scope=openid profile email&redirect_uri=localhost_url"; } </script> C# code:- public ActionResult Index(string code,string id_token) { if (code != null) { string postcontents = string.Format("client_id={0}&client_secret={1}&grant_type=authorization_code&redirect_uri={2}&code={3}" , System.Web.HttpUtility.UrlEncode("client_id") , System.Web.HttpUtility.UrlEncode("C

Categories : Asp Net Mvc

android-async-http library get http response header from Response Handler
@Zapnologica, it seems, that author of library provided changes based on this pull request: https://github.com/loopj/android-async-http/pull/170 But it is not released yet, at least latest available .jar version of library is 1.4.3 and it does not include these changes, unfortunately. The only option we may try to use is cloning/forking git repo and including its sources into your project. UPDATE: Seems library will soon be added to maven central repo, but at least now I was able to add 1.4.4 SNAPSHOT build using gradle for my project with such config changes: repositories { ... //android-async-client repo maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } } And then in dependencies section: compile 'com.loopj.android:android-async-http:1.

Categories : Android

"Bad Request" response on Tumblr's API "quote" request
From the documentation, the quote type requires a "quote" field instead of a "text" field. Change your parameters to this and it should work: $options = array('type' => 'quote', 'quote' => 'Text', 'source' => 'Source', 'tags' => 'Test'); Granted, it looks like the TumblrAPIRequestException doesn't return a helpful error message. I was able to figure this out by hacking TumblrAPIRequestException and putting a var_dump in the constructor: public function __construct($response) { $error = json_decode($response->body); var_dump($error->response); ... With that, I was at least able to get a good error message: class stdClass#668 (1) { public $errors => array(1) { [0] => string(21) "Post cannot be empty." } }

Categories : PHP

Node.js` "http.get" doesn't return full response body to a browser but just a piece of tag. How to get full response?
Your data event is firing multiple times, but you can only "end" your output once... you should probably refactor your handler as follows... // In /myapppath http.get("http://stackoverflow.com/", function(result) { var responseParts = []; result.setEncoding('utf8'); result.on("data", function(chunk) { //add this chunk to the output to send responseParts.push(chunk); }); result.on("end", function(){ //now send your complete response res.end(responseParts.join('')); }); });

Categories : Node Js

laravel 4: why is Request::header() not getting the specified header?
Request::header() is indeed used for the retrieval of headers, but check where the token is being set.. the CSRF token should be placed into the session by Laravel, and then it can be accessed through the Session::token() method. If you look at the HTML generated through calls to the Form:: class, you'll see a hidden element called _token, which should then be compared to the token in the session. You can access that using Input::get('_token'), as with any other incoming GET or POST variable. ...However, all this shouldn't really be necessary, as it can be managed easily through the pre-defined CSRF filter in filters.php, just add that filter to the desired route or route group and you'll be protected, without having to get into the details of it.

Categories : PHP

Spring Android Get Request implementation : Could not extract response: no suitable HttpMessageConverter found for response type and content type
Your server returns an XML content but says it returns HTML content (content type is text/html according to the error message) and thus the parsing failed. You need to make sure your server returns something like text/xml and also that you have the correct converters in you rest template object. Edit: Try to add this message converter. Put it first (before StringHttpMessageConverter and SourceHttpMessageConverter) Jaxb2RootElementHttpMessageConverter jaxbMessageConverter = new Jaxb2RootElementHttpMessageConverter(); List<MediaType> mediaTypes = new ArrayList<MediaType>(); mediaTypes.add(MediaType.TEXT_HTML); jaxbMessageConverter.setSupportedMediaTypes(mediaTypes); messageConverters .add(jaxbMessageConverter);

Categories : Android

Multiple request pools with node.js request module
I'm not sure if I get your question right - maybe because I've never used the request module. But, by reading the module README, I think you could, in some file of your project, export a function which defaults some options for you. Somewhat like this: function createRequest( url, callback ) { return request({ pool: { maxSockets: 25 }, // Maybe more things here url: url }, callback ); } Hope it helps you

Categories : Javascript

Is there any difference between using request.body or request.params in node.js?
You can fit more (diverse) data in the body than in the url. You can pass any string (special characters) in the body, while encoding them in the url would get you vulnerable to status 414 (Request-URI Too Long). And it's a lot easier to use the body when passing arrays and complex objects :)

Categories : Node Js

How to set response header in spring mvc
public String addUser(@Valid User user, BindingResult bindingResult,HttpServletRequest request,HttpServletResponse response) { if(bindingResult.hasErrors()) { bindingResult.getFieldError(); return"edit"; } response.setHeader("Cache-Control","no-cache,no-store,must-revalidate"); response.setHeader("Pragma","no-cache"); response.setDateHeader("Expires", 0); return "redirect:/welcome/profile/"+user.getName(); }

Categories : Java

Response header: Pragma: No-cache
By default Oracle Web Gate uses by default cache control no-cache and pragma no-cache. see the doc here : http://docs.oracle.com/cd/E22203_01/doc.31/e20664/chapter_12.htm at the bottom of the page

Categories : Caching

Impossible to have a 304 response when using maxage header
You made a mistake, $response->isNotModified($request) is used only when using cache validation with a ETag or a Last-Modified test! Here, you want to use expiration methods (with Cache-Control or Expires). So just remove theses lines : if ($response->isNotModified($request)) { return $response; } $response->setMaxAge(3600); (and setSharedMaxAge) alone will do the job, you don't need to test anything, the framework (or client navigator) will do it for you. The same response will be served during 3600 second without passing by the action. After 3600 seconds, the user will pass by the action anew and it will be cached for 3600 seconds, etc. In addition, you can use @Cache annotation which simplify the read ;)

Categories : Caching

AngularJS passing Response as header/Web API
I'm not sure you can share data from one service to another service without passing the data as a parameter to a method or constructor. e.g. //inside of a service this.makeAPIcall = function(token){ $http.get('http://...', {headers: {'Authorization': 'Basic ' + token}}); } But you likely want to store the authentication key for future http requests anyway and it would be best to store this key in a way that wouldn't require you to ask for authentication each time you need to make a request. I suggest you store your token in the browser's localstorage or as a cookie so that you can retrieve the token through the term for which the user is logged in. As a side note, if you find that you're going to have to pass the Authorization header each time you make an API call, you may wan

Categories : Angularjs

modify response header without using xpcom in firefox
You don't need a GUI. There are several ways to get your code running: Create a bootstrapped (restartless) add-on, just like ReDisposition (The GUI parts there are not required) and register from your bootstrap.js. Create an SDK add-on and register from your main.js. Create an XPCOM component and register it for profile-after-change (run at startup, basically) and register once the component gets loaded. Or have a stub overlay, that will just load a JS code module and register in the module. (A little hackish for my taste, but anyway). Anyway, in the end, you'll need to register and observe http-examine-response and friends, no matter what method you use, or what See MDN for more documentation (and the firefox-addon wiki). Other than that, your question is too broad to tell you som

Categories : Javascript

How to create a image when a different header is already set (for a JSON response)
"In that function in order to create the PNG file I need put on the disc I have to declare a new header right?" No. Headers should only be sent to browsers. You don't need to send a header to write to disc.

Categories : PHP

Extracting from Response Header with Regular Expression
Try this: Location: [S]+?confirmationNumber=(d+) Your issue is the use of special characters in the string without escaping them - e.g.: ? and / Note my ? is not matching the question mark in front of confirmationNumber, but instead is making the [S]+ non-greedy. If you want to be explicit, your version should work if modified like this to escape the characters with special meaning: Location: http://test.regtest.com/cart/confirmation?confirmationNumber=(d+)?

Categories : Regex

MKNetworkKit how to get server response header with session cookie
-_-! Finally, after all that digging around, get the response header like this: -(void)login { NSMutableDictionary *params = [[NSMutableDictionary alloc] init]; [params setObject:@"testusername" forKey:@"username"]; [params setObject:@"abcdef123" forKey:@"password"]; MKNetworkOperation *op = [self.mkEngine operationWithPath:@"/auth/local.json" params:params httpMethod:@"POST"]; [op addCompletionHandler:^(MKNetworkOperation *completedOperation) { NSLog(@"response headers: %@", completedOperation.readonlyResponse.allHeaderFields); } errorHandler:^(MKNetworkOperation *completedOperation, NSError *error) { NSLog(@"Server error: %@", [error localizedDescription]); }]; [self.mkEngine enqueueOperation:op]; }

Categories : IOS

Http response header not getting modified in firefox extension always
Content-Type is one of the response headers that cannot be modified. The others are Content-Lenght, Content-Encoding, Trailer and Transfer-Encoding. However you can change the inherited contentType attribute of nsIHttpChannel (some restrictions apply).

Categories : Javascript

XMLHttpRequest with Pentaho Data Integration to get the response header
If the URL you're requesting is on a different domain then I can tell you that the server is not sending the correct headers to allow cross-domain resource sharing. Access-Control-Allow-Origin: * Without the server sending that header the only way to access any of the response (including headers) is if your script is running on the same domain (and protocol) or if you setup a proxy on your own server to get the data from the remote server. If I open up the JS console on this page and run: var req = new XMLHttpRequest(); req.open('GET', 'http://dati.toscana.it/it/storage/f/2012-07-26T160139/intoscana-arte-e-cultura.csv', false); req.send(null); console.log(req.getAllResponseHeaders()); I get the following output: XMLHttpRequest cannot load http://dati.toscana.it/it/storage/f/2012-07

Categories : Http

Get Server Date/Time from header.response using jQuery GET
Check how to read headers from AJAX request jQuery and AJAX response header You can just read the date header, but without using a server-side page (aspx, php) the web server will cache files like .txt, .js or .css, and to overwrite that you can pass 'cache' as false to jQuery AJAX so it will append a random query parameter to force the web server to refresh it. Note: You will need empty file(.js, .txt, ..) as the target of AJAX call

Categories : Jquery

How to send node.js http request via proxy (using require('http').request method)
According to http://nodejs.org/api/http.html#http_http_request_options_callback hostname: To support url.parse() hostname is preferred over host Should add this line when overwriting proxy informations. options.hostname = proxy.hostname;

Categories : Node Js

Can A Header Be Added & Body Modified In A Salesforce SOAP Response?
I don't believe you can directly add any kind SOAP headers in an Apex defined WebService methods. If you have absolutely no other option you could construct your own custom SOAP response via a REST web service (via @RestResource annotation) but that is a pretty ugly solution.

Categories : Web Services

How does a browser interpret a page with no charset in the response header or meta tag?
If no charset is found then it will read some amount of the HTML code from the page and then try to guess the encoding. If it cannot figure it out then it will default to the browser's default character set. Depending on the browser it will often be something like Windows-1252 (a superset of Latin-1 also called ISO 8859-1) or UTF-8. It is important that you set the character set yourself. There are vulnerabilities (at least in older versions of IE) where you can feed the browser malicious code that will run if the browser guesses wrongly or uses its default charset. Setting it in an HTTP header should always be done, and setting it in the HTML never hurts. Setting it as a header is usually done by the server. In Apache it is usually done in the httpd.conf file, but it can also be done i

Categories : HTML

how to clear cache of response header if the content(image) changed in asp.net
You don't. Once it's cached, it's cached. And that's exactly why I don't like caching. What you can do is add a parameter to the url, like http://www.whatever.com/images/myfile.jpg?no_cache=lastWriteTimeUTC

Categories : Javascript

Setting WWW-Authenticate response header within a DelegatingHandler causes havoc on w2k3
You need to install .net Framework 4.0.3. Prior versions of .net framework could not set the www-authenticate header. Get it here, more info on the issue is in KB2600211.

Categories : Dotnet

Node JS get key value pairs from header
Use the URL module http://nodejs.org/api/url.html Example: http://www.host.com:8080/path?name=daniel Takes a URL string, and return an object. url.parse(urlStr, [parseQueryString], [slashesDenoteHost]) var server = http.createServer(function (request, response) { var queryData = url.parse(request.url, true).query; response.writeHead(200, {"Content-Type": "text/plain"}); response.end('Hello ' + queryData.name + ' '); } In this example name is mapped to daniel.

Categories : Javascript

Can't get Java's GZIPInputStream to read "gzip" response from server when using "Range" header
You can use 'gunzip' to decompress it, just keep in mind that the first 50 bytes probably aren't enough for gzip to decompress anything (headers, dictionaries etc). Try this: wget -O- -q <URL> | head -c 50 | zcat with your URL to see whether normal gzip works where your code fails.

Categories : Java

Get request header from freemarker
FreeMarker itself doesn't define any HTTP related variables; it's not like JSP, it's a general purpose engine; it only sees variables that were passed to it, and it doesn't know what they are... they are just name-value pairs as far as FreeMarker is concerned. So if you need this information, then either you should pass it to FreeMarker in the actions (maybe globally with a filter or interceptor or whatever you have), or the web application framework should.

Categories : Ajax

Add Header To all outgoing CXF request
I already know two ways of doing this. One is to create your SOAP Handler and register it as JAX-WS handler in your Spring config. Check my answer here how to create a SOAP handler. As you want header to appear in the response (outgoing request) don't forget that you then need to check if the message is outbound, something like this would do: Boolean outbound = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (outbound) { //Modify your header. } The other, maybe more easier way. Put the header directly into CXF response context. Please note that this example is only proof of concepts, I don't know the situation in reality where you need credentials in the response. It will display how to add user credentials object into the header, you have to modify it depending

Categories : Spring

Set request header of a link
Hyperlinks can not hold header information. You may be able to set headers for an AJAX request, assuming the security conditions are met (same domain or CORS). Take a look at the jQuery AJAX reference to learn about sending an ajax request with headers

Categories : Javascript



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