Repository: awslabs/llrt
File: llrt_core/src/modules/http/response.rs (Rust)

Code before:
                content_type: None,
                content_encoding: None,
            },
            abort_receiver: None,
        })
    }

    #[qjs(static, rename = "json")]
    fn json_static(ctx: Ctx<'js>, body: Value<'js>, options: Opt<Object<'js>>) -> Result<Self> {
        let mut status = 200;
        let mut headers = None;
        let mut status_text = None;

        if let Some(opt) = options.0 {
            if let Some(status_opt) = opt.get("status")? {
                status = status_opt;
            }
            if let Some(headers_opt) = opt.get("headers")? {
                headers = Some(Headers::from_value(&ctx, headers_opt)?);
            }
            if let Some(status_text_opt) = opt.get("statusText")? {
                status_text = Some(status_text_opt);
            }
        }

        let headers = if let Some(headers) = headers {
            Class::instance(ctx.clone(), headers)
        } else {
            Class::instance(ctx.clone(), Headers::default())
        }?;

        let body = Some(BodyVariant::Provided(body));

        let body_attributes = BodyAttributes {
            content_type: headers.get("content-type")?,
            content_encoding: headers.get("content-encoding")?,
        };

        Ok(Self {
            body,
            method: "".into(),
            url: "".into(),
            start: Instant::now(),
            status,
            status_text,
            redirected: false,
            headers,
            body_attributes,
            abort_receiver: None,
        })
    }

Review comment (suggestion):
```rust
let headers = Class::instance(ctx.clone(),headers.unwrap_or_default())?;
```

Code after:
        })
    }

    #[qjs(static, rename = "json")]
    fn json_static(ctx: Ctx<'js>, body: Value<'js>, options: Opt<Object<'js>>) -> Result<Self> {
        let mut status = 200;
        let mut headers = None;
        let mut status_text = None;

        if let Some(opt) = options.0 {
            if let Some(status_opt) = opt.get("status")? {
                status = status_opt;
            }
            if let Some(headers_opt) = opt.get("headers")? {
                headers = Some(Headers::from_value(&ctx, headers_opt)?);
            }
            if let Some(status_text_opt) = opt.get("statusText")? {
                status_text = Some(status_text_opt);
            }
        }

        let headers = Class::instance(ctx.clone(), headers.unwrap_or_default())?;

        let body = Some(BodyVariant::Provided(body));

        let body_attributes = BodyAttributes {
            content_type: headers.get("content-type")?,
            content_encoding: headers.get("content-encoding")?,
        };

        Ok(Self {
            body,
            method: "".into(),
            url: "".into(),
            start: Instant::now(),
            status,
            status_text,
            redirected: false,
            headers,
            body_attributes,
            abort_receiver: None,
        })
    }

    #[qjs(static)]
    fn redirect(ctx: Ctx<'js>, url: String, status: Opt<u16>) -> Result<Self> {
        let status = status.0.unwrap_or(302_u16);

        let mut header = BTreeMap::new();
        header.insert("location".to_string(), Coerced(url.to_string()));
        let headers = Headers::from_map(header);