Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5ccc460e authored by vince-bourgmayer's avatar vince-bourgmayer
Browse files

add Licence to modified file

parent 835b6746
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
/* ownCloud Android Library is available under MIT license
 *   Copyright (C) 2015 ownCloud Inc.
 *   Copyright (C) 2012  Bartek Przybylski
 *   Copyright (C) 2018 Vincent Bourgmayer (/e/ Foundation)
 *
 *   Permission is hereby granted, free of charge, to any person obtaining a copy
 *   of this software and associated documentation files (the "Software"), to deal
@@ -334,11 +335,12 @@ public class OwnCloudClient extends HttpClient {
    }

    /**
     *
     * @todo : need to be verify!
     * Decompress response from Gzip compression
     * @param responseBodyAsStream      InputStream with the HTTP response to exhaust.
     */
    public void exhaustGZippedResponse(InputStream responseBodyAsStream) {

        if (responseBodyAsStream != null) {
            try {
                while(responseBodyAsStream.read(sExhaustBuffer) >= 0);
+29 −13
Original line number Diff line number Diff line
package com.owncloud.android.lib.common.method;
/*
 * @Author: vincent Bourgmayer (/e/ Foundation)
 *
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.owncloud.android.lib.common.method;

import android.util.Log;

import org.apache.jackrabbit.webdav.client.methods.PropFindMethod;
import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
@@ -11,39 +28,38 @@ import org.xml.sax.SAXException;

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.util.zip.GZIPInputStream;

import javax.xml.parsers.ParserConfigurationException;

public class GzipedPropfind extends PropFindMethod {

    public GzipedPropfind(String uri) throws IOException {
        super(uri);
    }

    /*
     * @inherited;
     */
    @Override
    public Document getResponseBodyAsDocument() throws IOException {
        /*if ( super.responseDocument != null) {
            // response has already been read
            return super.responseDocument;
        }*/
        if(getResponseHeader("Content-Encoding").getValue() != "gzip") {
            return super.getResponseBodyAsDocument();
        }

        //@TOdo: look for potential optimisation like pipe gzipInputStream directly in InputStream in

        GZIPInputStream gzipis = null;
        gzipis = new GZIPInputStream(getResponseBodyAsStream());
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(gzipis));

        StringBuilder s = new StringBuilder();
        String line = null;
        while( (line =bufferedReader.readLine()) != null) {
            s.append(line);
        }
        Log.d("GzipedPropfind.java", s.toString() );

        InputStream in = new ByteArrayInputStream(s.toString().getBytes());
        if (in != null) {
+4 −6
Original line number Diff line number Diff line
/* ownCloud Android Library is available under MIT license
 *   Copyright (C) 2015 ownCloud Inc.
 *   Copyright (C) 2018 Vincent Bourgmayer (/e/ Foundation)
 *   
 *   Permission is hereby granted, free of charge, to any person obtaining a copy
 *   of this software and associated documentation files (the "Software"), to deal
@@ -39,7 +40,6 @@ import org.apache.jackrabbit.webdav.DavConstants;
import org.apache.jackrabbit.webdav.MultiStatus;
import org.apache.jackrabbit.webdav.client.methods.PropFindMethod;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.zip.GZIPInputStream;

@@ -104,15 +104,10 @@ public class LightReadFolderRemoteOperation extends RemoteOperation {
            boolean isSuccess = (status == HttpStatus.SC_MULTI_STATUS || status == HttpStatus.SC_OK);
            
            if (isSuccess) {
                InputStream stream = query.getResponseBodyAsStream();




                // get data from remote folder
                MultiStatus dataInServer = query.getResponseBodyAsMultiStatus();
                readData(dataInServer, client);

                // Result of the operation
                result = new RemoteOperationResult(true, query);
                // Add data to the result
@@ -120,6 +115,9 @@ public class LightReadFolderRemoteOperation extends RemoteOperation {
                    result.setData(mFolderAndFiles);
                }
            } else {

                //@THis need to be check!

                GZIPInputStream gzipSteam = null;
                gzipSteam = new GZIPInputStream(query.getResponseBodyAsStream());
                // synchronization failed