httprequest

Umlauts broken when doing get request

社会主义新天地 提交于 2019-12-11 19:48:38
问题 I'm trying to query a webservice which answers with plain text. The text often has german umlauts in it. In the received stream the umlauts are broken. Any ideas what am I doing wrong? Regards, Torsten Here is the sample code: var request = require('request'); var uri = <anUriWithUserId>; request(uri, {encoding: 'utf8','content-type': 'text/plain; charset=UTF-8'}, function (error, response, body) { console.log("encoding: " + response.headers['content-encoding']); console.log("type: " +

Uploading txt file via POST request with HttpBuilder

六月ゝ 毕业季﹏ 提交于 2019-12-11 18:18:24
问题 I want to upload a txt file to a website using a POST request with HTTPBuilder and multipart/form-data I've tried running my function and I get a HTTP 200 OK response, but the file doesn't appear on the website anywhere. private Map fileUpload(String url, File file){ log.debug "doPost: $url body: ${file.getName()}" FileBody fileBody = new FileBody(file,ContentType.APPLICATION_OCTET_STREAM) def result = [:] try { def authSite = new HTTPBuilder(url) authSite.auth.basic(user, password) authSite

Getting Shibboleth Attributes through Struts-1

安稳与你 提交于 2019-12-11 17:57:01
问题 I'm trying to integrate Shibboleth authentication with an old Struts-1 application that I've inherited the maintenance of, but I cannot figure out how to acecss the Shibboleth attributes. This is what I have tried: public final class AuthenticateAction extends MappingDispatchAction { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { Enumeration attributeNames = request.getAttributeNames(); while

Observables: Creating a mock http request

点点圈 提交于 2019-12-11 17:45:06
问题 I'm trying to test my front-end code without the back-end api using observables. In my component's template I have a textarea. Ultimately I need to send the textarea content to back-end api using http.post and receive back the validation for the content. In the constructor of my component.ts I define an observable which does some very basic checks and creates mock results after a timeout of 2000ms (like http.post/http.get): private obsVal: Observable < any >; private obsChange: Observable <

Azure Functions - How to use the `MultipartHttpServletRequest` class from the default `run()` method?

给你一囗甜甜゛ 提交于 2019-12-11 16:58:44
问题 public HttpResponseMessage run( @HttpTrigger(name = "req", methods = {HttpMethod.GET, HttpMethod.POST}, authLevel = AuthorizationLevel.FUNCTION) HttpRequestMessage<Optional<String>> request, final ExecutionContext context) { There's only HttpRequestMessage parameter on the run() method in the Azure Functions(Java) spec. I need to declare and use MultipartHttpServletRequest to fetch a file from the multipart/data request. I'm trying but cannot see any way to cast HttpRequestMessag to

How to execute the same curl request on a sequence of server IPs (URLs)

霸气de小男生 提交于 2019-12-11 15:57:29
问题 Command curl -v -H "Accept: application/json" -H "Content-type: application/json" \ -X POST -d '{"test": "some data"}' http://XX.XX.X.001:8080/services/test I want to execute the above same curl command on different servers (IP addresses). Is there any way or CURL command so I can execute this service on all servers, instead of changing the IP address every time manually? I have servers IP in some sequence, e.g. http://XX.XX.X.002:8080/services/test http://XX.XX.X.003:8080/services/test ...

how to do multi-part video upload using api

邮差的信 提交于 2019-12-11 15:23:22
问题 What is multi-part video upload and how it is done in asp.net. I have used below code to create project and get list using API HttpWebRequest wRequest = (HttpWebRequest)WebRequest.Create("apiurl?paramerters"); wRequest.Method = "POST"; string credentials = String.Format("{0}:{1}", "username", "password"); byte[] bytes = Encoding.ASCII.GetBytes(credentials); string base64 = Convert.ToBase64String(bytes); string authorization = String.Concat("Basic ", base64); wRequest.Headers.Add(

How do you mix up java with html and javascript?

天大地大妈咪最大 提交于 2019-12-11 15:02:30
问题 I have this little java project in which I have to use jsp files. I have an html with a login button that triggers the following function: var loginCall = "user/login"; var logoutCall = "user/logout"; var signupCall = "user/signup"; function login() { var login = baseUrl + loginCall + "?"; var loginFormElements = document.forms.loginForm.elements; login = addParam(login, USER_NAME, loginFormElements.userName.value, false); login = addParam(login, PASSWORD, loginFormElements.password.value,

Upload multiform data

倾然丶 夕夏残阳落幕 提交于 2019-12-11 13:38:02
问题 Helo I tryed to upload some data to my webserver. whit curl works fine curl -s -uedoweb-admin:admin -F"data=@/home/raul/test/t1/6376990.pdf;type=application/pdf" -XPUT api.localhost/resource/frl:6376979/data and here the trace http://pastebin.com/jJmungAy here the new methode. URL myurl; HttpURLConnection conn; String port = "9000"; String user = "edoweb-admin"; String password = "admin"; String encoding = Base64.encodeBase64String((user + ":" + password).getBytes()); String boundary = "==" +

Rest-Client Ruby Gem: Help creating get request with Headers, Query, and setting a proxy

孤者浪人 提交于 2019-12-11 13:14:28
问题 So far this is what I've come up with. RestClient.proxy = ENV("http_proxy") RestClient.head("Cookie","accessToken=#{@GottenTokenString}") #this line not working resp = RestClient.get("http://someServer/path/RestAPIPage.json",{:params => {:count => @count, :userCount => @userCount}}) The problem I have here is that I can't seem to add any headers to the get request. The API I am calling requires that a token be obtained and set to a cookie header. Seems that the REST API can't handle this. The