w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to send an image from HTTP client to http server listening on this URL(http://localhost:8000/test)
Are you using web container like apache/nginx or one you write it yourself? If you are wondering how to decode the tcp packet in your own server, just upload a file to a server and grasp the http packet to see the detail of the protocol

Categories : Misc

Handling HTTP Requests with C in Nginx
In order to serve compiled binary files with nginx, you need to run another server called FCGI, telling it the path to each binary you wish to serve, then configuring nginx to proxy connections to that server. Example configuration: http { server { listen 80; server_name localhost; location / { fastcgi_pass 127.0.0.1:8000; fastcgi_param GATEWAY_INTERFACE CGI/1.1; fastcgi_param SERVER_SOFTWARE nginx; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcg

Categories : C

Can not fetch the complete file from nginx with http.Get in GO
In this function you aren't closing the os.File. I suspect that is why it is going wrong. func (wtr *vFile) Write(buf []byte) { var f *os.File if wtr.cur == 0 { f,wtr.err = os.Create(wtr.path) } else { f,wtr.err = os.OpenFile(wtr.path,os.O_RDWR|os.O_APPEND,0666) } _, err := f.WriteAt(buf,twr.path) } If not post a complete compiling gofmt-ed example!

Categories : Http

nginX custom HTTP authorization , using scripts to decide
You can use the http_auth_request module. p.s. Do you actually know that nginx for windows is not production ready?

Categories : C

CloudFoundry / Nginx / Grails and the X-Forwarded Header (Missing)
I've never worked with Nginx, but it looks like you can add custom headers to the proxied request to the end server very easily. http://wiki.nginx.org/HttpProxyModule

Categories : Grails

Sending binary data using http
If the binary portion of your message are mere 4 bytes, percent-encode it and send it as an additional url-parameter. alternatively, add it to the existing xml stream. the java classes Uri and URLEncoder provide the necessary methods.

Categories : Java

URLencoding in HTTP request for space
because space is used as a separator in a lot of cases (program with arguments, HTTP commands, etc), so it often has to be escaped, with a in unix command line, with surroundings " in a windows command line, with %20 in URLs, etc. in HTTP protocol, when you try to reach http://www.foo.com, your browser opens a connection to the server www.foo.com on port 80, and send the commands: GET http://www.foo.com HTTP/1.0 Accept : text/html The syntax is "METHOD URL HTTPVERSION" If you tried to request http://www.foo.com/my page.html instead of http://www.foo.com/my%20page.html, the server would think "page.html" is the HTTPVersion you're looking for...

Categories : HTML

How can/should I limit the amount of HTTP requests within a given period of time?
This might be better handled by Nginx or Apache. Not every HTTP requests goes through your Rails application. For example, requests for static assets are often handled by Nginx/Apache directly. Moreover, as you scale your application, you might eventually have multiple Rails processes behind the same nginx server. For nginx, the HttpLimitReqModule might be what you need. When the limit is exceeded, the server will respond with 503 Service Temporarily Unavailable. A custom error page can be created for this status code. For apache, there is mod_ratelimit and mod_evasive. (This might be obvious, but an additional advantage of handling rate limits in nginx/apache is that requests over the limit don't even go into your Rails processes. Nginx/Apache will cut them off immediately, potentially

Categories : Ruby On Rails

Getting binary content in node.js with http.request
You need to set encoding to response, not request: req = https.request(options, function(res) { res.setEncoding('binary'); // this var data = ""; res.on('data', function(chunk) { return data += chunk; }); res.on('end', function() { return loadFile(data); }); res.on('error', function(err) { console.log("Error during HTTP request"); console.log(err.message); }); }); Here is useful answer: node.js Writing image to local server

Categories : Node Js

PHP: Http request fails from remote server
My guess is that your URL is malformed. Here's what the 400 code means. "The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications."

Categories : PHP

node.js http.get hangs after 5 requests to remote site
Here's the reason of the "exactly 5": https://nodejs.org/docs/v0.10.36/api/http.html#http_agent_maxsockets Internally, the http module uses an agent class to manage HTTP requests. That agent will, by default, allow for a maximum of 5 open connections to the same HTTP server. In your code, you don't consume the actual response sent by Google. So the agent assumes that you're not done with the request, and will keep the connection open. And so after 5 requests, the agent won't allow you to create a new connection anymore and will start waiting for any of the existing connections to complete. The obvious solution would be to just consume the data: http.get("http://www.google.com", function(r){ r.on('data', function() { /* do nothing */ }); ... }); If you run into the problem that yo

Categories : Node Js

are multiple linear white space allowed in http header
Yes, but see http://greenbytes.de/tech/webdav/draft-ietf-httpbis-p1-messaging-22.html#rfc.section.3.2.4.p.3 - it's deprecated in the upcoming revision of the HTTP spec.

Categories : Http

program using WWW-Mechanize Module for Http headers
The synopsis says: WWW::Mechanize is a proper subclass of LWP::UserAgent and you can also use any of LWP::UserAgent's methods. use strict; use warnings; use WWW::Mechanize; my $mech = WWW::Mechanize->new(); $mech->get( 'http://www.example.com' ); print $mech->dump_headers(); print " ==OR== "; my $header = HTTP::Request->new(GET => 'http://www.example.com'); my $request = HTTP::Request->new('GET', 'http://www.example.com', $header); my $response = $mech->request($request); print $response->headers_as_string; Prints: Connection: close Date: Wed, 26 Jun 2013 03:57:01 GMT Accept-Ranges: bytes ETag: "780602-4f6-4db31b2978ec0" Server: ECS (mdw/13C6) Content-Length: 1270 Content-Type: text/html; charset=UTF-8 Last-Modified: Thu, 25 Apr 2013 16:13:

Categories : Perl

How to use web module of Python in Eclipse for HTTP server
I assume you are using http://webpy.org I tried to run your app: $ pip install web.py Downloading/unpacking web.py Downloading web.py-0.37.tar.gz (90kB): 90kB downloaded Running setup.py egg_info for package web.py Installing collected packages: web.py Running setup.py install for web.py Successfully installed web.py Cleaning up... running yor code shows a problem: $ python test.py Traceback (most recent call last): File "test.py", line 21, in <module> app.run() NameError: name 'app' is not defined When I replace app.run() with pytest.run() if __name__ == "__main__": pytest.run() Everything works fine: $ python test.py http://0.0.0.0:8080/ If you run this form within eclipse and your are using a virtualenv, them make sure that you add the virtualenv (

Categories : Windows

Making HTTP request from an apache2 module (c++)
I am guessing you are on your own with the HTTP client. Probably the easiest way to make an HTTP connection is to use libcurl. On linux it should be installable from your distro's repositories.

Categories : C++

Blackberry 10: How to correspond incoming http replies to their previous http request counterparts?
You have at least two ways to do this: From the QNetworkReply, you can access to your original request (https://developer.blackberry.com/cascades/reference/qnetworkreply.html#request), on which you can set an originatingObject: https://developer.blackberry.com/cascades/reference/qnetworkrequest.html#setOriginatingObject, and any other attribute on your request You can check against the content URL: https://developer.blackberry.com/cascades/reference/qnetworkreply.html#url

Categories : C++

Use JMeter HTTP Proxy to record JSON over HTTP request from not-a-browser client
You can see my question and the answer I got below: Use Jmeter proxy to record HTTP calls from iOS simulator In short: With this tutorial you can record calls from your Android device: http://blazemeter.com/blog/load-testing-mobile-apps-made-easy For make same thing with iPhone, do the following steps: Mac configuration: system preferences -> Network -> Advanced.. -> Proxies -> check "Web Proxy (HTTP) ->in "Web Proxy Server" field, type your IP (http://www.wikihow.com/Find-Your-IP-Address-on-a-Mac), and choose available port (I using 8080) ->ok -> Apply iPhone configuration: Settings -> WiFi -> choose same wifi you use with your Mac -> press on it again to go to it's details -> scroll down ->In HTTP proxy, choose Manual -> server = your mac IP you found earlier -> port = the port yo

Categories : Http

Is it reasonable to assume that all HTTP headers (of a single HTTP message) arrive in the same SSL/TLS record?
No, cookies alone could be well above 16K. According to RFC2109 and IE implementation for cookie limits the recommended minimum restriction on cookie size per domain is 80K RFC 2109 section "6.3 Implementation Limits": at least 4096 bytes per cookie (as measured by the size of the characters that comprise the cookie non-terminal in the syntax description of the Set-Cookie header) at least 20 cookies per unique host or domain name

Categories : C

Text FIle - Access forbidden through http://localhost but OK if accessed http://private-ip ( LAMP )
Solved - looks like this was due to me keeping the doc root in a folder under /home. Once i switched that back to the /srv/www/htdocs folder , everything was ok. I made no other changes in the httpd.conf. - App/My work has been stable for a few weeks already

Categories : PHP

Configure IIS Windows Authentication to return HTTP 403 instead of HTTP 401 for permission denied with an authenticated user
What did not work I tried just about every IIS configuration permutation with no luck. I goofed around with the Windows authentication provider settings, like NTLM, Negotiate, and Negotiate:Kerberos. None of them seemed to do the trick. This isn't too much of a surprise since the browsers are deciding to try authentication again, even though they probably shouldn't. 401 Unauthorized The request requires user authentication. The response MUST include a WWW-Authenticate header field (section 14.47) containing a challenge applicable to the requested resource. The client MAY repeat the request with a suitable Authorization header field (section 14.8). If the request already included Authorization credentials, then the 401 response indicates that authorization has been refu

Categories : Asp Net

Writing a custom http server, does supporting AJAX require extra code over HTTP GET?
AJAX is fine, it's just GET (or occasionally POST) requests which are formatted exactly the same on the server side. The difference on the server is, they'll typically go to a different "servlet" (or method in your C code) to be answered. Typically, the answer may be XML, JSON (serialized data for Javascript) or perhaps an HTML fragment (without or tags, just the content of a or something.). Or it could just be a 200 OO response indicating "success". On the browser side, AJAX is requested & used from Javascript within a page; with the results then either pasted into the DOM via innerHtml (for HTML fragments), or built into the DOM via Javascript (for JSON). The second option is less performant. Your first typical use-case might well be an autocomplete for a search-box, or somet

Categories : C

Python HTTP request with controlled ordering of HTTP headers
You can try to use the OrderedDict class to store the headers, instead of request's default one: >>> from collections import OrderedDict >>> from requests import Session >>> s = Session() >>> s.headers CaseInsensitiveDict({'Accept-Encoding': ... 'User-Agent': ... 'Accept': '*/*'}) >>> s.headers = OrderedDict([('User-Agent', 'foo-bar'), ('Accept', 'nothing')]) >>> s.headers OrderedDict([('User-Agent', 'foo-bar'), ('Accept', 'nothing')])

Categories : Python

sun.net.www.protocol.http.HttpURLConnection - when will support http method PATCH?
The JDK HttpURLConnection doesn't support the HTTP PATCH method in JDK6, JDK7 nor JDK8. No official JDK roadmap shows this item for the moment. You can use Apache HTTPClient 4.2+ or AsyncHTTPClient.

Categories : Misc

Extracting elements from an HTTP XML response--HTTP Client & Java
Instead of trying to extract the value with string manipulation, try to use Java's inbuilt ability to parse XML. That's a much better approach. Http Components returns responses in an XML format - there's a reason for that. :) Here's probably one way to solve your problem: // Parse the response using DocumentBuilder so you can get at elements easily DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); Document doc = docBuilder.parse(response); Element root = doc.getDocumentElement(); // Now let's say you have not one, but 'n' nodes that contain the value // you're looking for. Use NodeList to get a list of all those nodes and just // pull out the tag/attrib

Categories : Java

HTTP request failed! HTTP/1.1 503 Service Temporarily Unavailable
503 means the functions are working and you're getting a response from the remote server denying you. If you ever tried to cURL google results the same thing happens, because they can detect the user-agent used by file_get_contents and cURL and as a result block those user agents. It's also possible that the server you're accessing from also has it's IP address blackballed for such practices. Mainly three common reasons why the commands wouldn't work just like the browser in a remote situation. 1) The default USER-AGENT has been blocked. 2) Your server's IP block has been blocked. 3) Remote host has a proxy detection.

Categories : PHP

Why does $_SERVER["SERVER_PROTOCOL"] show HTTP/1.0 when the client spoke HTTP/1.1
Interesting problem! You have two connections here because you have a end-point proxy in between. The request from your version of nginx to apache is going over HTTP 1.0. CLIENT <---- (HTTP 1.1) ----> NGINX <----- (HTTP 1.0) ----> SERVER Nginx 1.1.4 onwards supports HTTP 1.1 to upstream servers.

Categories : PHP

How to send text and binary data from a custom netty HTTP server in Java?
I do not think there is any more differenece between context or binary. I think what you need to do is set the content-type right. Then browser know how to handle it. If you want to send a png file to browser, set the content-type to "image/png".

Categories : Java

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

C HTTP Server & OpenSSL - Works fine for HTTP - Multiple/rapid/concurrent connections being dropped using HTTPS
You should call SSL_accept() in your request handling thread. This will allow your listening thread to process the TCP accept/listen queue more quickly, and reduce the chance of new connections getting a RESET from the TCP stack because of a full accept/listen queue. SSL handshake is compute intensive. I would guess that your spammer is probably not using SSL session cache, so this causes your server to use the maximum amount of CPU. This will cause it to be CPU starved in regards to servicing the other connections, or new incoming connections.

Categories : C

How to parse http Get request body in a Go http server?
Most of the magic happens in transfer.go. Here's what I found that looks relevant in the fixLength func: if !isResponse && requestMethod == "GET" { // RFC 2616 doesn't explicitly permit nor forbid an // entity-body on a GET request so we permit one if // declared, but we default to 0 here (not -1 below) // if there's no mention of a body. return 0, nil } Looks like, as long as your client is ending a Content-Length header, you're all good. If not, the library will assume there's no body on a GET request. You're kind of off the edge of the map as your client is doing some pretty unusual/broken stuff. If you can fix the client, that's your best bet. That said, if you have a client you need to support that's doing this wrong, you're going to have to roll so

Categories : Http

Which should be used when naming a variable in Objective C, "http" or "HTTP" prefix?
Honestly, it doesn't really matter. Rather than being worried about naming, you should make sure everything is clear and well spaced. Unless you have a name that is really similar or close to a class or method name, you should not worry about it. This is mainly a personal choice. Do whatever you want. Just make sure you can read it. |˙∆˙|/

Categories : Objective C

Angular JS cancel $http call before calling a new $http
You need to create a new canceler for each request, because once it's resolved it can't be used again. See here for an updated plnkr.

Categories : Http

Htaccess redirects http://www... to https://www..., but does not redirect http://www
Try this: RewriteEngine On #not https RewriteCond %{HTTPS} off RewriteRule .* https://www.metalmetalland.com%{REQUEST_URI} [R=301,L] #https, but not www RewriteCond %{HTTP_HOST} !^www. RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Categories : Apache

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

Get http 500 in a Azure worker role http request
One thought is that when you run your code in the cloud, you are running on their servers, meaning you dates could all be out of whack. I have seen it before where you assume DateTime.Now (or whatever you are doing) is your time, but its actually the server time of the VM you are running on in the cloud. The reason it could be a date issue is that I see you are passing in date parameters to the URL, perhaps they are formatted wrong when you are running in the cloud?

Categories : C#

handling $http.get and $http.post errors in Angularjs
Response interceptors are attached during the config phase of an angularjs app. You can use them to globally respond to any $http request. Be aware, template files also use $http request, so you may wish to filter some requests in your interceptor to only the ones you wish to respond to. A good understanding of the promises pattern is needed to successfully use response interceptors. Heres an example of how they are used: angular.module('services') .config(function($httpProvider){ //Here we're adding our interceptor. $httpProvider.responseInterceptors.push('globalInterceptor'); }) //Here we define our interceptor .factory('globalInterceptor', function($q){ //When the interceptor runs, it is passed a promise object return function(promise){

Categories : Angularjs

node.js / get request & define root folder in http module
It looks like you're trying to use the low-level socket module ('net') to implement an HTTP server. The correct module is 'http' (Node.js HTTP documentation), and the implementation is simple: Your client side: var http = require("http"); http.get("http://localhost:8001/pro.html", function(response) { response.setEncoding("utf8"); response.on("data", function(data) { console.log("response:", data); }); }).on("error", function(e) { console.log("Got err: " + e.message); }); And for the server side: var http = require("http"); var server = http.createServer(function(request, response) { response.end("Here's your pro page! ") }).listen(8001); Note that the above features an impractically-simple server that returns a fixed response without any regard

Categories : Node Js

Python module for HTTP: fill in forms, retrieve result
We cannot advise you with detailed instructions since you never gave us details of your problem. However, most probably you want to use urllib2 to fetch an HTML page: import urllib2 response = urllib2.urlopen('http://python.org/') html = response.read() You should then parse the form, find out all the data fields you need to send with their names , and then create your own POST or GET request, depending on the form type. To send a POST request: import urllib import urllib2 url = 'http://www.someserver.com/cgi-bin/register.cgi' values = {'name' : 'Michael Foord', 'location' : 'Northampton', 'language' : 'Python' } data = urllib.urlencode(values) req = urllib2.Request(url, data) response = urllib2.urlopen(req) the_page = response.read() To send a GET request: import url

Categories : Python

nginx as load balancer server out 404 page based on HTTP response from app server
Simply set the proxy_intercept_errors option to on and create an nginx error page for it. error_page 404 /404.html; proxy_intercept_errors on; To ensure that nginx will serve the static file from it’s document root you also have to specify the following: location /404.html { internal; } I'm assuming here that nginx is configured to talk with your app servers as proxy, because that is the usual way and your question does not mention any of this.

Categories : Nginx

turn http post request to http get
You should not do this as the semantics are different. GET requests are designed to be cached (i.e. usually static stuff). POST on the other hand is more dynamic and is not cached. You are very likely to get undesired behaviour if you do this.

Categories : Java



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