Skip to content

Commit

Permalink
Bugfix: passing query arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
f3l1x committed Sep 4, 2019
1 parent 4e8d204 commit 1ab298e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
@@ -1,6 +1,10 @@
## [Unreleased]

## [php] [0.0.2][@latest] - 2019-08-23
## [php] [0.0.3][@latest] - 2019-09-04

- Bugfix passing query parameters and accessing $_GET

## [php] [0.0.2] - 2019-08-23

- Bump now-php@latest

Expand All @@ -10,7 +14,7 @@
- Bugfix resolving PHP bin
- Bugfix deploying php files in subfolders

## [php] [0.0.2-canary.1][@canary] - 2019-08-16
## [php-lib] [0.0.2-canary.2][@canary] - 2019-08-16

- Compile PHP 7.3.8

Expand Down
2 changes: 1 addition & 1 deletion examples/php-test/index.php
@@ -1,3 +1,3 @@
<?php

echo "+ěščřžýáíéů§";
var_dump($_GET);
12 changes: 9 additions & 3 deletions packages/php/src/launchers/builtin.ts
@@ -1,7 +1,7 @@
import http from 'http';
import { spawn, ChildProcess, SpawnOptions } from 'child_process';
import net from 'net';
import path from 'path';
import url from 'url';
import {
getPhpDir,
normalizeEvent,
Expand Down Expand Up @@ -62,17 +62,23 @@ async function query({ filename, uri, headers, method, body }: PhpInput): Promis
await startServer();
}

// Parse request URL and join with PHP lambda file.
// E.q domain.tld/?foo=bar
// Path is /var/task/user/index.php/?foo=bar
const {search} = url.parse(uri);
const path = filename + (search || '');

return new Promise(resolve => {
const options = {
hostname: '127.0.0.1',
port: 8000,
path: `${filename}`,
path,
method,
headers,
};

console.log(`🐘 Accessing ${uri}`);
console.log(`🐘 Querying ${filename}`);
console.log(`🐘 Querying ${path}`);

const req = http.request(options, (res) => {
const chunks: Uint8Array[] = [];
Expand Down

0 comments on commit 1ab298e

Please sign in to comment.