httpurlconnection

Verifying CXF HttpAsyncClient use of use.async.http.conduit contextual property

孤街浪徒 提交于 2019-12-01 22:29:41
I am trying to make use of the CXF asynchronous HTTP client transport, through setting the "use.async.http.conduit" property, as detailed in this thread , and recommended by this CXF article . I do that using the following code: Client client = ClientProxy.getClient(wsClient); client.getRequestContext().put("use.async.http.conduit", Boolean.TRUE); As it happens, my web service call is timing out (probably due to some environmental network issue), and my client exception contains (extract): java.net.SocketTimeoutException: Read timed out at java.net.SocketInputStream.read(SocketInputStream.java

Not able to send additional parameters with image using HttpURLConnection in android

£可爱£侵袭症+ 提交于 2019-12-01 22:28:46
public class UploadProfilePicActivity extends Activity implements View.OnClickListener { ImageView imageView; Button btnUploadPic; Button btnskipUploadPic; Button btnSaveNContinue; private static int RESULT_LOAD_IMAGE = 1; String imagepath = null; ProgressDialog dialog = null; String url_profilePic; private int serverResponseCode; String api = "http://192.168.2.17:8000/api/v1/"; String format = "/?format=json"; AlmabayDatabase almabayDatabase; String encodedString; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout

HttpUrlConnection with post request and parameter as Json object android

被刻印的时光 ゝ 提交于 2019-12-01 21:51:49
Hi I am developing small android application in which I want to use HttpUrlConnection post request with params as json object. But its not working for me I did it in following way: try { URL url; DataOutputStream printout; DataInputStream input; url = new URL ("https://abc.com"); HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); urlConnection.setRequestMethod("POST"); urlConnection.setDoInput (true); urlConnection.setDoOutput (true); urlConnection.setUseCaches (false); urlConnection.setConnectTimeout(10000); urlConnection.setReadTimeout(10000); urlConnection

HttpURLConnection POST, conn.getOutputStream() throwing Exception

纵饮孤独 提交于 2019-12-01 20:43:15
I want to make a POST by using HttpURLConnection. I am trying this in 2 ways, but I always get an excetion when doing: conn.getOutputStream(); The exception I get in both cases is: java.net.SocketException: Operation timed out: connect:could be due to invalid address function1: public void makePost(String title, String comment, File file) { try { URL servlet = new URL("http://" + "www.server.com/daten/web/test/testupload.nsf/upload?CreateDocument"); HttpURLConnection conn=(HttpURLConnection)servlet.openConnection(); conn.setDoOutput(true); conn.setDoInput(true); conn.setUseCaches(false);

Maximum length of content?

倖福魔咒の 提交于 2019-12-01 18:29:57
I'm trying to connect with a server using HttpURLConnection , but I have a problem with the PUT method. I need to send a String with 1500 characters (or more), but in this case the server produces a timeout and returns 500 - server internal error . If I send a String lower than 1400 characters , I have not problem and the server returns OK . My code is the following: public String connectToServer(String prototype) { String responseString = ""; try { BufferedReader in = new BufferedReader(new InputStreamReader(openURLForInput(new URL(URL), USERNAME, PASSWORD, prototype))); String line; while (

Passing Parameters with HttpURLConnection

♀尐吖头ヾ 提交于 2019-12-01 17:44:36
问题 With the old Apache stuff deprecated in API 22, I am finally getting around to updating my network stuff. Using openConnection() seems pretty straight forward. However, I have not seen any good example to send parameters with it. How would I update this code? ArrayList<NameValuePair> param = new ArrayList<NameValuePair>(); param.add(new BasicNameValuePair("user_id",String.valueOf(userId))); httpPost.setEntity(new UrlEncodedFormEntity(param)); Now that NameValuePair and BasicNameValuePair are

Closing an HttpURLConnection before the response is complete

时间秒杀一切 提交于 2019-12-01 17:08:32
问题 Background I'm using HttpURLConnection on the client side to consume a response in an HTTP streaming (server push) situation. Although the server may close the connection by closing the response, there's also a need for the client to be able to do this. Problem The client processes the InputStream in a separate thread, like this: @Override public void run() { try { for (int b = in.read(); b >= 0; b = in.read()) { char c = (char) b; // Do something with the character // ... } } catch

Adding body of call to POST using HttpURLConnection

冷暖自知 提交于 2019-12-01 13:51:27
I am trying to use HTTPURLConnection make a POST method call to a server api. The JSON version of the body of my call is: { "grant_type" : "password", "username" : "perry.marange@zmod.co", "password" : "password" } How do I add this part using httpURLConnection? i think you can use the Android Rest-Client for sending data to a webservice take classes RequestMethod.java and RestClient.java from this link https://github.com/TylerSmithNet/RESTclient-Android/tree/master/RESTclient-example/src/com/tylersmith/restclient and use those in your project like this String webServiceUrl = "your-service-url

[Android]-POST Json with HttpUrlConnection

﹥>﹥吖頭↗ 提交于 2019-12-01 12:18:56
I build a server side to my application when I send a requests to this server with python-script its work good, but with my app it doesn't work. Server: the server contains a database. when I send a JSON {"name":"your_name"} the server save in the DB the name. App(Android): @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); buttonSend=(Button)findViewById(R.id.button_send); buttonSend.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AsyncTaskRunner postReq = new

EPIPE (Broken pipe) while uploading?

坚强是说给别人听的谎言 提交于 2019-12-01 07:46:01
i have a problem in my code but i don't know where is it the E log report 04-08 05:47:46.745: E/Upload Server(20080): Starting : /storage/sdcard1/Music/Piano (my favourites)/11 Tchaikovsky - The Music Lovers.mp3 04-08 05:47:47.136: E/Upload Server(20080): Connection Error : sendto failed: EPIPE (Broken pipe) what is (EPIPE) ? , when i attempt to upload image its upload successfully but any other file E Cat report (Broken pipe) why ! this is my uploading code @Override protected String doInBackground(String... urls) { String upLoadServerUri = "http://test.com/test.php"; String fileName = this