@Override public boolean getDoOutput() { return _conn.getDoOutput(); }
public boolean getDoOutput() { return delegateConnection.getDoOutput(); }
public boolean getDoOutput() { return connection.getDoOutput(); }
public boolean getDoOutput() { return connection.getDoOutput(); }
/** * Tests whether the application can modify the resource at the * specified {@link URL}. * * @return <CODE>true</CODE> if and only if the specified * {@link URL} points to a file that exists <EM>and</EM> the * application is allowed to write to the file; <CODE>false</CODE> * otherwise. * * @param url URL to check if we can write to. */ public boolean canWrite(URL url) { try { final URLConnection urlConnection = url.openConnection(); return urlConnection.getDoOutput(); } catch (Exception e) { return false; } }
public void makeXMLRequest() { try { URL url = new URL("http://api.androidhive.info/pizza/?format=xml"); HttpURLConnection con = (HttpURLConnection) url.openConnection(); con.setRequestMethod("GET"); con.getDoOutput(); String readStream = readStream(con.getInputStream()); // Give output for the command line System.out.println(readStream); } catch (Exception e) { e.printStackTrace(); } }
public void PutImageToS3(String signedUrl, Bitmap image) throws WampNetworkException, IOException { try{ URL url = new URL(signedUrl); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.getDoOutput(); conn.setUseCaches(false); conn.setRequestMethod("PUT"); conn.addRequestProperty("Content-Type", "image/jpeg"); conn.addRequestProperty("Connection", "close"); OutputStream out = new BufferedOutputStream(conn.getOutputStream()); image.compress(Bitmap.CompressFormat.JPEG, 100, out); if (conn.getResponseCode() != HttpURLConnection.HTTP_OK) { throw new IOException("Failed to upload image to S3: " + conn.getResponseCode() + conn.getResponseMessage() + "\r\n"); } } finally{ out.flush(); out.close(); conn.disconnect(); } }
private void openConnection(HttpURLConnection connection, HttpRequest request) throws IOException { if (request.getHttpBody() != null) { connection.setDoOutput(true); } connection.setRequestMethod(request.getMethod()); Map<String, String> map = request.getHeaders(); for (Map.Entry<String, String> entry : map.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); Logger.i("prepare headers with key = " + key + " value = " + value); connection.setRequestProperty(entry.getKey(), entry.getValue()); } connection.setReadTimeout((int) mReadTimeout); connection.setConnectTimeout((int) mConnectionTimeout); if (connection.getDoOutput()) { connection.connect(); } }
if (!conn.getDoOutput()) { conn.setDoOutput(true); os = conn.getOutputStream();
if (urlConnection.getDoOutput()) { OutputStream outputStream = null; try {
/** * Should be called when a <code>Connection</code> is used to do a POST (write to it's outputstream) * without reading it's inputstream (the response). Calling this will make sure the POST request is sent. * If no data was written to the connection nothing is done. */ public void close() { if (m_connection.getDoOutput()) { try { m_connection.getOutputStream().close(); } catch (IOException e) { // not much we can do } try { m_connection.getContent(); } catch (IOException e) { // not much we can do } } if (m_connection.getDoInput()) { try { m_connection.getInputStream().close(); } catch (IOException e) { // not much we can do } } } }
if (conn.getDoOutput()) conn.getOutputStream().close(); reader.close();
if (conn.getDoOutput()) conn.getOutputStream().close(); reader.close();
public void testUrlConnectionForEventData() throws IOException { final String eventData = "blahblahblah"; final URLConnection urlConnection = connectionProcessor.urlConnectionForEventData(eventData); assertEquals(30000, urlConnection.getConnectTimeout()); assertEquals(30000, urlConnection.getReadTimeout()); assertFalse(urlConnection.getUseCaches()); assertTrue(urlConnection.getDoInput()); assertFalse(urlConnection.getDoOutput()); assertEquals(new URL(connectionProcessor.getServerURL() + "/i?" + eventData + "&checksum=" + sha1Hash(eventData + null)), urlConnection.getURL()); }