Thread: Content-Type in form variables

Content-Type in form variables

From
Dennis Gearon
Date:
If I receive a form via POST or PUT with with mulitple variables, files, application/json, others, is there anywhere in
theenvironment to test he mime type of each variable? 

POST /en/html/dummy.php HTTP/1.1
Host: www.explainth.at
User-Agent: Mozilla/5.0 (Windows;en-GB; rv:1.8.0.11) Gecko/20070312 Firefox/1.5.0.11
Accept: text/xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-gb,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://www.explainth.at/en/misc/httpreq.shtml?txt=
Content-Type: multipart/form-data; boundary=---------------------------103832778631715
Content-Length: 355

-----------------------------103832778631715
Content-Disposition: form-data; name="JSON_OBJS"
Content-Type: application/json

{
    "variable_name": 8675309
    "blob_value": NULL
}
-----------------------------103832778631715
Content-Disposition: form-data; name="blob_value"; filename="previous.png"

Content-Type: image/png



‰PNG


-----------------------------103832778631715

Dennis Gearon

Signature Warning
----------------
EARTH has a Right To Life

I agree with Bolivian President Evo Morales

# The right to life: "The right for no ecosystem to be eliminated by the irresponsible acts of human beings."

# The right of biosystems to regenerate themselves: "Development cannot be infinite. There's a limit on everything."

# The right to a clean life: "The right for Mother Earth to live without contamination, pollution. Fish and animals and
treeshave rights." 

# The right to harmony and balance between everyone and everything: "We are all interdependent."


See the movie - 'Inconvenient Truth'
See the movie - 'Syriana'

Re: Content-Type in form variables

From
Sam Mason
Date:
On Sat, Jul 25, 2009 at 11:12:15AM -0700, Dennis Gearon wrote:
> If I receive a form via POST or PUT with with mulitple variables,
> files, application/json, others, is there anywhere in the environment
> to test he mime type of each variable?

?? this doesn't seem particularly related to PG!  Anyway...

mime-types are conventionally associated with files, not variables.
if you want to do input validation maybe you could write (or find) a
parser? a set of regexs are normally easy and formal enough for simple
purposes.

Most languages contain code for parsing mime encoded documents; python
makes this sort of thing reasonably easy if you want to stay reasonably
low level or there are lots of frameworks around to simplify things.

--
  Sam  http://samason.me.uk/

Re: Content-Type in form variables

From
Dennis Gearon
Date:
Sorry,

pgsql-general? php-general? who can tell the difference while your eyes are still focusing from long hours on the
comptuer?

Sorry guys.

PS, no wonder it didn't show up or get answered from the php guys ;-)


<Sam Mason <sam@samason.me.uk>wrote>
Subject: Re: Content-Type in form variables
Message-ID: <20090726012447.GQ5407@samason.me.uk>

On Sat, Jul 25, 2009 at 11:12:15AM -0700, Dennis Gearon wrote:
> If I receive a form via POST or PUT with with mulitple variables,
> files, application/json, others, is there anywhere in the environment
> to test he mime type of each variable?

?? this doesn't seem particularly related to PG!  Anyway...

mime-types are conventionally associated with files, not variables.
if you want to do input validation maybe you could write (or find) a
parser? a set of regexs are normally easy and formal enough for simple
purposes.

Most languages contain code for parsing mime encoded documents; python
makes this sort of thing reasonably easy if you want to stay reasonably
low level or there are lots of frameworks around to simplify things.

--
  Sam  http://samason.me.uk/

------------------------------

End of [pgsql-general] Daily digest v1.9201 (20 messages)
**********

Re: Content-Type in form variables

From
Jasen Betts
Date:
On 2009-07-25, Dennis Gearon <gearond@sbcglobal.net> wrote:

> If I receive a form via POST or PUT with with mulitple variables, files, application/json, others, is there anywhere
inthe environment to test he mime type of each variable? 
> POST /en/html/dummy.php HTTP/1.1

looks like a PHP question to me
http://nz2.php.net/manual/en/reserved.variables.files.php