Comments (3)
I am really swamped atm. I don't know how soon I can get to it. I created a bounty to incentivize others.
from multipartposthandler.
From Stack Ovewrflow:
I'm using MultipartPostHandler to create multi part-form data requests.
We are using lighttpd web server and our cgi-bin folder is protected with username and password.
Whenever we access the cgi files, we need to authenticate.
This works fine when there are no parameters attached to the request, but fails with any parameters.
Could you please help me how I can authenticate when using parameters in the request ?
import MultipartPostHandler
import urllib2
def handle_authentication(url):
"""handle_authentication description"""
try:
passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, url, USERNAME, PASSWORD)
authhandler = urllib2.HTTPBasicAuthHandler(passman)
opener = urllib2.build_opener(authhandler)
urllib2.install_opener(opener)
except urllib2.HTTPError:
print ERROR_300
sys.exit(1)
Also:
params = {'BoardType': board_type, 'SataConfigFile': open(input_path, 'rb')}
opener = urllib2.build_opener(MultipartPostHandler.MultipartPostHandler)
print opener
try:
handle_authentication(url)
response = opener.open(url, params)
Do you have a solution?
from multipartposthandler.
The solution is as follows - clubbing both (authentication and the Multi part request) request will solve the purpose for now. Is there any better solution available ??
import MultipartPostHandler
import urllib2
def handle_authentication(url):
"""handle_authentication description"""
try:
passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, url, USERNAME, PASSWORD)
authhandler = urllib2.HTTPBasicAuthHandler(passman)
return authhandler
except urllib2.HTTPError:
print ERROR_300
sys.exit(1)
Then in the main code . . .
params = {'BoardType': board_type, 'SataConfigFile': open(input_path, 'rb')}
authhandler = handle_authentication(url)
opener = urllib2.build_opener(authhandler, MultipartPostHandler.MultipartPostHandler)
print opener
try:
handle_authentication(url)
response = opener.open(url, params)
from multipartposthandler.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from multipartposthandler.