{"id":18010442,"url":"https://github.com/aviranabady/woodpecker","last_synced_at":"2025-03-26T14:32:02.619Z","repository":{"id":186157449,"uuid":"92505416","full_name":"AviranAbady/woodpecker","owner":"AviranAbady","description":"woodpecker http client for Android","archived":false,"fork":false,"pushed_at":"2017-06-19T06:03:42.000Z","size":3235,"stargazers_count":18,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-21T23:23:59.158Z","etag":null,"topics":["android","chain","chain-requests","chaining","delete","get","http","http-client","htttp-request","network","post","promise","put"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AviranAbady.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-05-26T11:44:20.000Z","updated_at":"2023-09-17T09:07:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"054742d5-1072-4448-a8b9-d519b05a99c0","html_url":"https://github.com/AviranAbady/woodpecker","commit_stats":null,"previous_names":["aviranabady/woodpecker"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AviranAbady%2Fwoodpecker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AviranAbady%2Fwoodpecker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AviranAbady%2Fwoodpecker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AviranAbady%2Fwoodpecker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AviranAbady","download_url":"https://codeload.github.com/AviranAbady/woodpecker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245670822,"owners_count":20653431,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","chain","chain-requests","chaining","delete","get","http","http-client","htttp-request","network","post","promise","put"],"created_at":"2024-10-30T02:14:25.244Z","updated_at":"2025-03-26T14:32:01.813Z","avatar_url":"https://github.com/AviranAbady.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# woodpecker\n\nLean HTTP client for Android.\u003cbr/\u003e\nAiming to provide simplicity, minimal setup, chain requests without nesting code blocks.\u003cbr/\u003e\nGET, POST, PUT, HEAD requests are supported.\u003cbr/\u003e\nUpstream/Downstream progress listeners are available for upload/download progress tracking.\u003cbr/\u003e\n\u003cbr/\u003e\nSee it in action, \u003ca href=\"https://github.com/AviranAbady/woodpecker-demo\"\u003eAndroid demo project\u003c/a\u003e.\n\n### Integrate\n```gradle\ncompile 'org.aviran.woodpecker:woodpecker:0.9.1'\n```\n\n\u003cimg src=\"http://i.imgur.com/35jFhoU.gif\"/\u003e\n\n\n### Over the top proof of concept\nThe following scenario fires 6 http requests in a row, passing data from one to the other when\n necessary.\u003cbr/\u003e\n Quick initialization, build the request chain without nesting them inside each other's\n response callbacks.\u003cbr/\u003e\n```java\n// Initialize Woodpecker\nWoodpecker.initialize(new WoodpeckerSettings(\"http://woodpecker.aviran.org\"));\n\n// Run the following 6 requests, consecutively, passing data from one to the other.\n\n// POST  login    /login - post body: username=user\u0026password=password\n// GET   list     /list?page=1\u0026pageSize=10\n// GET   item     /item/{id}\n// POST  review   /review - post body: { name: Aviran, review: This is awesome }\n// GET   get      /image.png - download binary file\n// PUT   upload   /upload - upload binary image file\n\nWoodpecker\n  .begin()  // POST /login\n  .request(new LoginRequest(\"username\", \"p@ssw0rd\"))\n  .then(new WoodpeckerResponse\u003cLoginResponse\u003e() {\n      @Override\n      public void onSuccess(LoginResponse response) {\n          // Update authentication token for the follwing requests\n          Woodpecker.getSettings().addHeader(\"token\", response.getToken());\n      }\n  })       // GET /list?page=1\u0026pageSize=10\n  .request(new ListRequest(1, 10))\n  .then(new WoodpeckerResponse\u003cList\u003cItemResponse\u003e\u003e() {\n      @Override\n      public void onSuccess(List\u003cItemResponse\u003e response) {\n          // Get next request object\n          ItemRequest itemRequest = (ItemRequest) getNextRequest();\n          // Update it\n          itemRequest.setId(response.get(0).getId());\n      }\n  })      // GET /item/{id}   - id is updated in run time by previous request\n  .request(new ItemRequest(-1))\n  .then(new WoodpeckerResponse\u003cItemResponse\u003e() {\n      @Override\n      public void onSuccess(ItemResponse response) {\n      }\n  })      // POST /review  - JSON encoded post\n  .request(new ReviewRequest(1, \"Aviran\", \"This is awesome!\"))\n  .then(new WoodpeckerResponse\u003cString\u003e() {\n      @Override\n      public void onSuccess(String response) {\n      }\n  })      // GET /image.png - request with progress tracking\n  .request(new DownloadFileRequest(progressListener))\n  .then(new WoodpeckerResponse\u003cInputStream\u003e() {\n      @Override\n      public void onSuccess(InputStream response) {\n      }\n  })      // POST multipart data - 2 files uploaded, progress tracking\n  .request(createFileUploadRequest())\n  .then(new WoodpeckerResponse\u003cUploadResponse\u003e() {\n      @Override\n      public void onSuccess(UploadResponse response) {\n      }\n  })     // Error handler for the entire chain\n  .error(new WoodpeckerError() {\n      @Override\n      public void onError(WoodpeckerResponse response) {\n      }\n  });\n```\n\n### Login api call is defined by the following request/response classes\n```java\n@Post(\"/login\")\npublic class LoginRequest extends WoodpeckerRequest {\n    @Param // @Param used to define 'username' as a request data parameter\n    private String username;\n\n    @Param\n    private String password;\n\n    public LoginRequest(String username, String password) {\n        this.username = username;\n        this.password = password;\n    }\n}\n\n// POJO structure to the response of LoginRequest\npublic class LoginResponse {\n    private String token;\n\n    public String getToken() {\n        return token;\n    }\n}\n```\n\n### Item api call - Demonstrating usage of url path variable\n```java\n@Get(\"/item/{id}\")\npublic class ItemRequest extends WoodpeckerRequest {\n    @Path\n    private int id;\n\n    public ItemRequest(int id) {\n        this.id = id;\n    }\n\n    public void setId(int id) {\n        this.id = id;\n    }\n}\n```\n\n### Review api call - Demonstrating posting JSON body\n```java\n@Post(\"/review\")\npublic class ReviewRequest extends WoodpeckerRequest {\n    // @Param is not used in this class, therefore class structure\n    // will be serialized to json, and will be sent as request body.\n    private int itemId;\n    private String name;\n    private String text;\n\n    public ReviewRequest(int itemId, String name, String text) {\n        this.itemId = itemId;\n        this.name = name;\n        this.text = text;\n    }\n}\n```\n\n### GET'ing binary file, with download progress tracking\n```java\n// Progress listener that will be supplied to the request,\n// will be executed on the UI Thread.\nprogressListener = new WoodpeckerProgressListener() {\n    @Override\n    public void onProgress(String name, int progress, int totalSize) {\n        // log progress / totalSize\n    }\n}\n\n// By using the @Progress annotation, this request will invoke progress\n// notification calls to the supplied listener\n@Get(\"/woodpecker.jpg\")\npublic class DownloadFileRequest extends WoodpeckerRequest {\n    @Progress\n    WoodpeckerProgressListener progressListener;\n\n    public DownloadFileRequest(WoodpeckerProgressListener progressListener) {\n        this.progressListener = progressListener;\n    }\n}\n```\n\n### POST multipart, with upload progress tracking\n```java\n@Post(\"/upload\")\npublic class UploadRequest extends WoodpeckerRequest {\n    @Param\n    private String uploadToken;\n\n    @File\n    private WoodpeckerFileStream fileUpload;\n\n    @File\n    private WoodpeckerFileStream anotherFileUpload;\n\n    @Progress\n    private WoodpeckerProgressListener progressListener;\n\n    public UploadRequest(String uploadToken,\n                         WoodpeckerFileStream fileUpload,\n                         WoodpeckerFileStream anotherFileUpload,\n                         WoodpeckerProgressListener progressListener) {\n        this.uploadToken = uploadToken;\n        this.fileUpload = fileUpload;\n        this.anotherFileUpload = anotherFileUpload;\n        this.progressListener = progressListener;\n    }\n}\n```\n\nLicense\n=======\n\n    Copyright 2017 Aviran Abady.\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faviranabady%2Fwoodpecker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faviranabady%2Fwoodpecker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faviranabady%2Fwoodpecker/lists"}