Skip to content

Commit

Permalink
rename files to match library name
Browse files Browse the repository at this point in the history
  • Loading branch information
plageoj committed Dec 23, 2022
1 parent d050ff6 commit e4b42f6
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ An Arduino library for building HTTP requests.
WiFiClient client;

void postRequest(){
Request *request = new RequestBuilder(
RequestBuilder *request = new RequestBuilder(
"POST",
"example.com",
"/path/to/resource"
Expand Down Expand Up @@ -76,7 +76,7 @@ Concatenate two parameters, overwriting the original parameter.

Sort the parameter by key alphabetically.

### Request
### RequestBuilder

A class for building HTTP requests.

Expand Down
2 changes: 1 addition & 1 deletion examples/GetRequest/GetRequest.ino
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void setup() {
}

// Create a new request
Request *request = new Request(
RequestBuilder *request = new RequestBuilder(
"GET",
"www.google.com",
"/search");
Expand Down
2 changes: 1 addition & 1 deletion examples/PostRequest/PostRequest.ino
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void setup() {
}

// Create a new request
Request *request = new Request(
RequestBuilder *request = new RequestBuilder(
"POST",
"httpbin.org",
"/post");
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
],
"platforms": "*",
"headers": [
"Request.h"
"RequestBuilder.h"
],
"examples": [],
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ paragraph=for making complex requests. Useful for making request with multipart/
category=Communication
url=https://github.com/plageoj/request-builder
architectures=*
includes=Request.h
includes=RequestBuilder.h
depends=UrlEncode
14 changes: 7 additions & 7 deletions src/Request.cpp → src/RequestBuilder.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include "Request.h"
#include "RequestBuilder.h"
#include <algorithm>

#include <UrlEncode.h>

Request::Request() {
RequestBuilder::RequestBuilder() {
}

String Request::getRequestLine() {
String RequestBuilder::getRequestLine() {
String ret = this->method + " " + this->path;
String paramStr = this->query.get();
if (!paramStr.isEmpty()) {
Expand All @@ -16,7 +16,7 @@ String Request::getRequestLine() {
return ret;
}

String Request::getRequestHeader() {
String RequestBuilder::getRequestHeader() {
this->header.add("Host", this->host);
if (this->body.size() > 0) {
this->header.add("Content-Type", "application/x-www-form-urlencoded");
Expand All @@ -25,15 +25,15 @@ String Request::getRequestHeader() {
return this->header.getRaw("\r\n", ": ") + "\r\n";
}

String Request::getRequest() {
String RequestBuilder::getRequest() {
String ret = this->getRequestLine();
ret += this->getRequestHeader();
ret += "\r\n";
ret += this->body.get();
return ret;
}

String Request::getParameterString() {
String RequestBuilder::getParameterString() {
Parameter temp;
temp.concat(this->auth);
temp.concat(this->query);
Expand All @@ -42,6 +42,6 @@ String Request::getParameterString() {
return temp.get();
}

String Request::getUrl(String protocol) {
String RequestBuilder::getUrl(String protocol) {
return protocol + "://" + this->host + this->path;
}
10 changes: 5 additions & 5 deletions src/Request.h → src/RequestBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@
/**
* Represents a HTTP request.
*/
class Request {
class RequestBuilder {
public:
Request();
RequestBuilder();

/**
* Set the HTTP method of the request.
* @param method The HTTP method to set (like GET, POST).
*/
Request(String method) {
RequestBuilder(String method) {
this->method = method;
};
/**
* Set the HTTP method and host of the request.
* @param method The HTTP method to set (like GET, POST).
* @param path The host of the request (like www.example.com).
*/
Request(String method, String host) {
RequestBuilder(String method, String host) {
this->method = method;
this->host = host;
};
Expand All @@ -34,7 +34,7 @@ class Request {
* @param host The host of the request (like www.example.com).
* @param path The path of the request (like /path/to/file.html).
*/
Request(String method, String host, String path) {
RequestBuilder(String method, String host, String path) {
this->method = method;
this->host = host;
this->path = path;
Expand Down

0 comments on commit e4b42f6

Please sign in to comment.