Retrofit 2.0-beta-2 is adding literal quotes to MultiPart values

This is because it’s running through the JSON converter. Solution1: use RequestBody instead of String public interface ApiInterface { @Multipart @POST(“user/login/”) Call<SessionToken> userLogin(@Part(“username”) RequestBody username, @Part(“password”) RequestBody password); } Build RequestBody: RequestBody usernameBody = RequestBody.create(MediaType.parse(“text/plain”), usernameStr); RequestBody passwordBody = RequestBody.create(MediaType.parse(“text/plain”), passwordStr); Launch network operation: retrofit.create(ApiInterface.class).userLogin(usernameBody , passwordBody).enqueue()…. Solution2: Create a custom ConverterFactory to dispose String … Read more

What port does httpclient use?

There are always two ports involved in a connection – one at the server, and another at the client. The server-side port is specified (and is known to the client) via the HTTP URL (the default is 80 for HTTP connections and 443 for HTTPS) and is specified after the hostname using hostname:port notation. On … Read more

Should I cache and reuse HttpClient created from HttpClientFactory?

HttpClient is only IDisposable because its HttpMessageHandler is IDisposable. In reality, it’s the HttpMessageHandler which should be long-lived. HttpClientFactory works by keeping a long-lived HttpMessageHandler internally. Whenever you ask for a HttpClient, it uses the long-lived HttpMessageHander, and tells the HttpClient not to dispose it when the HttpClient is disposed. You can see that on … Read more

proxy authentication in node.js with module request

Here is an example of how to configure (https://github.com/mikeal/request/issues/894): //…some stuff to get my proxy config (credentials, host and port) var proxyUrl = “http://” + user + “:” + password + “@” + host + “:” + port; var proxiedRequest = request.defaults({‘proxy’: proxyUrl}); proxiedRequest.get(“http://foo.bar”, function (err, resp, body) { … })

Java NoSuchAlgorithmException – SunJSSE, sun.security.ssl.SSLContextImpl$DefaultSSLContext

Well after doing some more searching I discovered the error may be related to other issues as invalid keystores, passwords etc. I then remembered that I had set two VM arguments for when I was testing SSL for my network connectivity. I removed the following VM arguments to fix the problem: -Djavax.net.ssl.keyStore=mySrvKeystore -Djavax.net.ssl.keyStorePassword=123456 Note: this … Read more

How to determine a 404 response status when using the HttpClient.GetAsync()

You could simply check the StatusCode property of the response: static async void dotest(string url) { using (HttpClient client = new HttpClient()) { HttpResponseMessage response = await client.GetAsync(url); if (response.IsSuccessStatusCode) { Console.WriteLine(response.StatusCode.ToString()); } else { // problems handling here Console.WriteLine( “Error occurred, the status code is: {0}”, response.StatusCode ); } } }

Android HttpClient persistent cookies

You can do what @Emmanuel suggested or you can pass the BasicHttpContext between the HttpClients you are creating. Example Use of context and cookies, complete code here HttpClient httpclient = new DefaultHttpClient(); // Create a local instance of cookie store CookieStore cookieStore = new BasicCookieStore(); // Create local HTTP context HttpContext localContext = new BasicHttpContext(); … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)