How to retrieve raw post data from HttpServletRequest in java

I’m trying to get the post data in Java. Seems like it should be one of the simplest things to do right? I mean, HttpServletRequest.getParameter has to do it right? So how can you get the raw post data? I found HttpServletRequest get JSON POST data and used Kdeveloper’s code to pull the post data … Read more

How to specify an authenticated proxy for a python http connection?

What’s the best way to specify a proxy with username and password for an http connection in python? Answer This works for me: import urllib2 proxy = urllib2.ProxyHandler({‘http’: ‘http:// username:password@proxyurl:proxyport’}) auth = urllib2.HTTPBasicAuthHandler() opener = urllib2.build_opener(proxy, auth, urllib2.HTTPHandler) urllib2.install_opener(opener) conn = urllib2.urlopen(‘http://python.org’) return_str = conn.read() AttributionSource : Link , Question Author : Rehan , Answer … Read more

How to stop BaseHTTPServer.serve_forever() in a BaseHTTPRequestHandler subclass?

I am running my HTTPServer in a separate thread (using the threading module which has no way to stop threads…) and want to stop serving requests when the main thread also shuts down. The Python documentation states that BaseHTTPServer.HTTPServer is a subclass of SocketServer.TCPServer, which supports a shutdown method, but it is missing in HTTPServer. … Read more

http download file name

May i know how to assign a file-name to a a-href file download. <a href=”http://localhost:8080/couch/getFile?dbName=xxx&file=test.xml”>get-file</a> On right-clicking and Save as: A services running on the background will return test.xml contents and the user can save it locally. But here everytime user needs to type a filename for saving. Instead i’m thinking to pull the test.xml. … Read more

Python’s `urllib2`: Why do I get error 403 when I `urlopen` a Wikipedia page?

I have a strange bug when trying to urlopen a certain page from Wikipedia. This is the page: http://en.wikipedia.org/wiki/OpenCola_(drink) This is the shell session: >>> f = urllib2.urlopen(‘http://en.wikipedia.org/wiki/OpenCola_(drink)’) Traceback (most recent call last): File “C:\Program Files\Wing IDE 4.0\src\debug\tserver\_sandbox.py”, line 1, in <module> # Used internally for debug sandbox under external interpreter File “c:\Python26\Lib\urllib2.py”, line 126, … Read more

Download text/csv content as files from server in Angular

I am trying to stream a csv file from a node.js server. The server portion is very simple : server.get(‘/orders’ function(req, res) { res.setHeader(‘content-type’, ‘text/csv’); res.setHeader(‘content-disposition’, ‘attachment; filename=’orders.csv’); return orders.pipe(res); // assuming orders is a csv file readable stream (doesn’t have to be a stream, can be a normal response) } In my angular controller … Read more

How to get access token from HttpContext in .Net core 2.0

I’m trying to upgrade a project from .Net core 1.1 to .Net core 2.0 there’s a lot of breaking changes. One of the things I’m currently having an issue with is that HttpContext.Authentication is now obsolete. I’ve been trying to figure out how to get the Access token for the current request. I need to … Read more

How to redirect HTTP to HTTPS in MVC application (IIS7.5)

I need to redirect my HTTP site to HTTPS, have added below rule but I am getting 403 Error when tried using http://www.example.com, it works fine when I type https://www.example.com in browser. <system.webServer> <rewrite> <rules> <rule name=”HTTP to HTTPS redirect” stopProcessing=”true”> <match url=”(.*)” /> <conditions> <add input=”{HTTPS}” pattern=”off” ignoreCase=”true” /> </conditions> <action type=”Redirect” redirectType=”Found” url=”https://{HTTP_HOST}/{R:1}” … Read more