Aaronong opened a new pull request #10771:
URL: https://github.com/apache/druid/pull/10771


   ### Description
   
   Currently, Protobuf Descriptors can only be retrieved from the local 
filesystem, or unauthorized URLs. 
   
   This commit introduces the ability to retrieve descriptors via authenticated 
URLs.
   
   <hr>
   
   This PR has:
   - [X] been self-reviewed.
   - [ ] added documentation for new or modified features or behaviors.
   - [ ] added Javadocs for most classes and all non-trivial methods. Linked 
related entities via Javadoc links.
   - [ ] added or updated version, license, or notice information in 
[licenses.yaml](https://github.com/apache/druid/blob/master/licenses.yaml)
   - [ ] added comments explaining the "why" and the intent of the code 
wherever would not be obvious for an unfamiliar reader.
   - [ ] added unit tests or modified existing tests to cover new code paths, 
ensuring the threshold for [code 
coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md)
 is met.
   - [ ] added integration tests.
   - [ ] been tested in a test Druid cluster.
   
   <hr> 
   
   No unit tests were added since a test relying on an actual authenticated 
https get request would be flaky at best. 
   
   Wrote a simple hello world script to check that it works.
   
   ```
   package hello;
   import java.io.IOException;
   import java.io.InputStream;
   import java.net.URL;
   import java.net.URLConnection;
   import java.nio.charset.StandardCharsets;
   import java.util.Base64;
   
   public class HelloWorld {
     public static void main(String[] args) {
       try {
         //   URL url = new URL("http://user:[email protected]/url";);
         URL url = new URL(
             
"https://github.com/apache/druid/blob/master/docs/development/build.md";);
         URLConnection urlConnection = url.openConnection();
         if (url.getUserInfo() != null) {
           String basicAuth = "Basic " + Base64.getEncoder().encodeToString(
                                             url.getUserInfo().getBytes());
           urlConnection.setRequestProperty("Authorization", basicAuth);
         }
         InputStream in = urlConnection.getInputStream();
   
         System.out.println("FILE: " +
                            new String(in.readAllBytes(), 
StandardCharsets.UTF_8));
       } catch (IOException e) {
         System.out.println("Cannot read descriptor file: " + e.getMessage());
       }
     }
   }
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to