saqibpitafi / google-gdata

Automatically exported from code.google.com/p/google-gdata
0 stars 0 forks source link

Proxy problem with spreadsheets #234

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello,

I have problems setting proxy. I use .NET Client Library.

I'm working on a new version of GDocBackup http://gs.fhtino.it/gdocbackup 
I'd like to support environments where connections must go through proxy
servers. All works fine if download Document or Presentations but I get
errors if I try to download Spreadsheets.

The first step works fine:

GDataCredentials credentials = new GDataCredentials(_userName, _password);
RequestSettings settings = new RequestSettings("GDocBackup", credentials);
DocumentsRequest request = new DocumentsRequest(settings);

GDataRequestFactory x= request.Service.RequestFactory as GDataRequestFactory;
x.Proxy = new WebProxy();   // ... or another proxy.

Feed<Document> feed = request.GetEverything();
List<Document> _docs = new List<Document>();
foreach (Document entry in feed.Entries)
   _docs.Add(entry);

Second step:  I download docs (the real code is more complex):

foreach (Document doc in _docs)
{
     if (... skip folder and pdf...)
     {
        Stream stream = request.Download(doc, Document.DownloadType.pdf);
        using (FileStream outFile = new FileStream("out.pdf",
FileMode.Create, FileAccess.Write))
        {..  save stream to local disk...}
     }
}

I get an exception at line  Stream stream = request.Download(doc,
Document.DownloadType.pdf);
I get the error only if I'm downloading a spreadsheet.
FYI the error is a proxy required authentication 407. But the problem
is not the exception.  I try to explain.

I looked at the source code of the NET Lib and if I download a doc,
the lib uses the proxy I set. And I get no error.
If I download a spreadsheet, the lib use the "default" proxy and I get
the error.

So, why the lib use my proxy with doc and another proxy with
spreadsheets?

   Fabrizio 

----------
Originally posted at:

http://groups.google.com/group/Google-Docs-Data-APIs/browse_thread/thread/1f5063
b1f1f11841

Original issue reported on code.google.com by fht...@gmail.com on 10 Apr 2009 at 11:36

GoogleCodeExporter commented 9 years ago
What source code in the spreadsheet dll is setting the default proxy? If it is 
that's a bug. Can you pinpoint the 
source in the spreadsheet lib that is doing this?

Frank

Original comment by fman...@gmail.com on 14 Apr 2009 at 1:15

GoogleCodeExporter commented 9 years ago
Hello Frank,

perhaps I was not very clear. I try to explain a bit more.

STEP 1:

In my app I set the proxy using a code like this:

GDataRequestFactory x = request.Service.RequestFactory as GDataRequestFactory;
x.Proxy = Utility.GetProxy(...);

Utility.GetProxy returns an instance of IWebProxy.

STEP 2:

I get the Doc list:

Feed<Document> feed = request.GetEverything();
List<Document> _docs = new List<Document>();
foreach (Document entry in feed.Entries)
   _docs.Add(entry);

The proxy I set in Step 1 is correctly used. OK!

Step 3

I download the documents.  

Stream stream = request.Download(doc, Document.DownloadType.pdf);

If doc is a Document, the proxy is used: OK!
If doc is a Spreadsheet, the proxy is NOT used: ERROR!

.
.
.
In my previous message I wrote "default" proxy because HttpWebRequest/WebRequest
classes use the proxy configured in Internet Explorer.  In my test PC I have a 
proxy
configured in IE but I need to use another one during the tests of my app. So I 
set
it using:

GDataRequestFactory x= request.Service.RequestFactory as GDataRequestFactory;
x.Proxy = Utility.GetProxy(...);

But the Lib uses the new proxy only for getting the doc list and for downloading
Document. But uses the "default" (--> IE) proxy for downloading spreadsheets.

   Fabrizio

Original comment by fht...@gmail.com on 14 Apr 2009 at 2:06

GoogleCodeExporter commented 9 years ago
Ok. Got it. The problem is that the documentrequest object uses 2 services 
instances (due to some doclist service 
side issues). One for docs and one for spreadsheets. When you set up the proxy 
like this, you are only setting it 
up for the documents part of the service. 

I did the following (in subversion now). FeedRequest has a Proxy property now 
that you should be able to use. It 
calls a virtual in the setter that the DocumentRequest uses to set the proxy on 
both services. Can you try if that 
fixes your issue (you have to rebuild the dlls yourself). 

Original comment by fman...@gmail.com on 14 Apr 2009 at 2:34

GoogleCodeExporter commented 9 years ago
Hello Frank

it works fine!  Thank you.  :)

I removed:

GDataRequestFactory gdrf = request.Service.RequestFactory as 
GDataRequestFactory;
gdrf.Proxy = _iwebproxy;

and I added:

request.Proxy = Utility.GetProxy(...);

(request is a DocumentsRequest)

Now my apps get doc list, download documents and spreadsheets. And uses proxy 
correctly.

Last question: when will you release the new official version of the Lib with 
the new
feature?  have you a plan/date?

   fabrizio

Original comment by fht...@gmail.com on 14 Apr 2009 at 3:07

GoogleCodeExporter commented 9 years ago
That depends on the amount of changes that will happen between 2 given points. 
There is a high overhead 
releasing (create setup, documentation, test on 4 platforms etc...), so i only 
do that when sufficient changes 
happened inbetween releases.

Original comment by fman...@gmail.com on 14 Apr 2009 at 4:24