chore: refactor
This commit is contained in:
@@ -37,7 +37,12 @@ pub const HttpHeader = struct {
|
||||
value: []const u8,
|
||||
};
|
||||
|
||||
pub const HttpContext = struct { client: *const Client, request: *const HttpRequest, response: ?*const HttpResponse = null, finished: bool = false };
|
||||
pub const HttpContext = struct {
|
||||
client: *const Client,
|
||||
request: *const HttpRequest,
|
||||
response: ?*const HttpResponse = null,
|
||||
finished: bool = false,
|
||||
};
|
||||
|
||||
fn tcp_recv_callback(context: ?*anyopaque, pcb: ?*cNet.tcp_pcb, p1: ?*cNet.pbuf, _: cNet.err_t) callconv(.C) cNet.err_t {
|
||||
if (p1 == null) {
|
||||
@@ -164,7 +169,9 @@ pub const Client = struct {
|
||||
print("Client.sendRequest");
|
||||
var context: HttpContext = .{ .client = client, .request = request };
|
||||
|
||||
{
|
||||
cNet.cyw43_arch_lwip_begin();
|
||||
defer cNet.cyw43_arch_lwip_end();
|
||||
var cached_address = cNet.ip_addr_t{};
|
||||
|
||||
const host = if (request.url.host) |host| host else unreachable;
|
||||
@@ -197,7 +204,8 @@ pub const Client = struct {
|
||||
}
|
||||
|
||||
print("Calling cyw43_arch_lwip_end");
|
||||
cNet.cyw43_arch_lwip_end();
|
||||
}
|
||||
|
||||
print("Ending sendRequest...");
|
||||
|
||||
while (!context.finished) {
|
||||
|
||||
@@ -40,7 +40,6 @@ const appSettings: AppSettings = x: {
|
||||
};
|
||||
};
|
||||
|
||||
// Basically the pico_w blink sample
|
||||
export fn main() c_int {
|
||||
_ = p.stdio_init_all();
|
||||
p.sleep_ms(2000);
|
||||
|
||||
Reference in New Issue
Block a user