Hi, I'm using wconnect 5.72 and I'm generating a post call with tokens and binary image - all parameters all together is around 366 characters long. Call doesn't work. If I use postman with exactly same parameters and file - all works well. It makes me thinking that this version of wconnect has a limit in URL length. Does anyone know if latest version has this fixed or I'm missing something ?
This is browser/client specific. Some browsers restrict the URL to 256 characters. I think that would be really old browsers - newer browsers don't balk at large URLs AFAIK.
If Postman to the same URL works, then the server is working, no?
+++ Rick ---
Hmmm. The call is from desktop app - I'm not sure how browser is involved here... Server works just fine. Postman call works, http server is returning 200 OK and image is correctly transferred to the server but from desktop app I'm always getting "Invalid token". I checked many times - I'm passing valid,correct token but it's very long... Let me show the code and sample data:
Function image_push_v12
Lparameters lc_full_path, lc_guid, lc_access_key
If Vartype(m.lc_full_path)<>'C'
Return 'Path to file expected (character type)'
Else
If Len(m.lc_full_path)>=8 && "c:\a.doc"
*OK, proceed
If File(m.lc_full_path)
*OK
Else
Return 'file not found'
Endif
Else
Return 'file path expected'
Endif
Endif
If Vartype(m.lc_guid)<>'C'
Return 'GUID expected (char type)'
Else
*OK
Endif
If Vartype(m.lc_access_key)<>'C'
Return 'Image Access Key expected (char type)'
Else
*OK
MESSAGEBOX(LEN(m.lc_access_key))
Endif
*========================================================================================================
* HTTP WRITE part
Local lc_mime
m.lc_mime = get_mime(m.lc_full_path)
Local lc_file_ext, lc_filename && .PDF (with .)
m.lc_file_ext='.'+Alltrim(Justext(m.lc_full_path))
m.lc_filename=Justfname(m.lc_full_path) && just filename from path
* push image to server
loHttp = Createobject("wwHttp")
loHttp.nHttpPostMode=4 && XML or RAW (1-URL, 2-Multipart)
*** Specify that we want to post raw data and a custom content type
* IMPORTANT !!!! add ; otherwise it won't be received correctly...
*-BAD jpg image: 321501 (tested with VS 2013 debugger)
*ContentType: "; Name=\"\""
*-GOOD jpg image: 321507
*ContentType: "image/jpeg; Name=\"front.jpg\""
loHttp.cContentType = m.lc_mime &&+'; Name='+m.lc_filename && Content type of the data posted
*Messagebox("["+loHttp.cContentType+"]")
loHttp.cHttpVerb = "POST" && Use for anything but POST/GET verbs (PUT/DELETE/HEAD/OPTIONS)
*urlPath := '/'+ServerUrlPath + '/Insert' ;
Local lc_server_url
Local lc_access_key, lc_bucket_name
TEXT TO instr1 TEXTMERGE NOSHOW PRETEXT 15
SELECT IMS.SERVER_TYPE
,IMS.SERVER_IP
,IMS.SERVER_PORT
,IMS.url_path
,IMS.bucket_name
,IMS.SECURITY_KEY_1
FROM IMAGE_SERVER IMS
WHERE (default_flag='T')
ENDTEXT
ret1=SQLExec_q(m.instr1,'ims')
If m.ret1<0
Return .F.
Else
Select ims
m.lc_server_url='http://' + Alltrim(ims.server_ip) + ':' + Alltrim(Transform(ims.server_port)) + '/' + Alltrim(ims.url_path) + '/Insert'
m.lc_bucket_name=Alltrim(ims.bucket_name)
*---------------------------------------------------------
* ??????????????????/
*m.lc_access_key=ALLTRIM(ims.SECURITY_KEY_1)
*---------------------------------------------------------
Use In Select("ims")
Endif
*** Load up the data any way you need
Local l_filestream
l_filestream = Filetostr(m.lc_full_path)
*** Set the POST buffer - Note: No name parameter, just the buffer
loHttp.AddPostKey(l_filestream)
*** now add others
*IndyHttp.Request.CustomHeaders.Add('imagekey: '+ GUID);
*IndyHttp.Request.CustomHeaders.Add('filename: '+fileName);
*IndyHttp.Request.CustomHeaders.Add('fileext: '+ext);
*IndyHttp.Request.CustomHeaders.Add('bucketname: '+ BucketName)
*----------------------------------------------------------------------------
loHttp.AddPostKey('imagekey',m.lc_guid) && passed
loHttp.AddPostKey('securitykey',m.lc_access_key) && passed
loHttp.AddPostKey('filename',JUSTFNAME(m.lc_full_path))
loHttp.AddPostKey('fileext',m.lc_file_ext)
loHttp.AddPostKey('bucketname',m.lc_bucket_name) && have it
*loHttp.AddPostKey('Content-Type','image/jpeg')
*MESSAGEBOX(m.lc_server_url)
Local lcPostResult
m.lcPostResult = loHttp.HttpGet(m.lc_server_url)
If (loHttp.nError <> 0)
Return 'HTTP Error: '+Alltrim(Transform(loHttp.nError))
Else
*proceed
Endif
ShowHTML(lcPostResult)
*Local ln_id
*m.ln_id=Val(Alltrim(m.lcPostResult))
*If m.ln_id>0
* Return m.ln_id
*Else
* Return 'HTTP returned 0 as a key'
*Endif
Endfunc
Sample data:
securitykey:
OUQyRjNCNDE5MUY5RjA0NDI4NUVCMDJCREQ0RjU0RjM3MjA4RTE5MkIzNDREQTBGRDkzNjFFN0VFNTMzNzg3N0VDNkI4RDVGNjREQjZFRjhGOTQzNzg4MzAxQTg1QjVDODdBODFENzA4NDEzRUVENkJGNEIwREZEODY1MDRCQ0I0MDg5RUJGNEIwQkVCMEUwMDc5RUM0QkUyMkNGRkRBMA==
imagekey:
01F87AFBD35845F98C4407C94287EE6E
filename: image.jpg
fileext: .jpg
bucketname: qcs3v12
I think I posted into wrong forum.... This is about a post call from desktop app, which is using stand alone wwHTTP library...
*** The browser name (User Agent) that wwHTTP sends to the server cUserAgent = "West Wind Internet Protocols 5.0" &&+ TRANSFORM(WWVERSION_NUMBER)
from wconnect.h :
DEFINE WWVERSION "Version 5.72" #DEFINE WWVERSION_NUMBER 5.72 #DEFINE WWVERSIONDATE "April 21st, 2015"
That sounds you have an issue with client code.
I just checked (this is in v7 though):
DO wconnect
loHttp = CREATEOBJECT("wwHttp")
lcUrl = "https://west-wind.com/wconnect/testpage.wwd?" +;
REPLICATE("10&", 300)
? LEN(lcUrl)
lohttp.AddPostKey("LastName",REPLICATE("20&", 400))
lcHtml = loHttp.Post(lcUrl)
? loHttp.cErrorMsg
ShowHtml(lcHtml)
...and that works fine for me.
This sends a URL that has a 900 char querystring and that works fine. POST content can be any size (from the sending end) will depend on the server settings - there are basic limits that can be configured on the server.
If I recall there are still limits but it's somewhere closer to 2000 character I believe.
I guess you should try to figure out: Is the error coming from the client or the server. It's possible you're getting an unrelated error from the server that has nothing to do with the URL length but a generally invalid server url.s
+++ Rick ---
Yup - doing some quick tests it looks like the limit is somewhere around 2000 characters - running that code sample I can't send 700 replicates(), but 680 works - so somewhere around 2k on the URL seems about write.
In this case though it's the server that's rejecting it, not WinInet:
and that's probably configurable. This is configured in the IIS request limits I believe.
+++ Rick ---
Rick, Thanks for spending your time and checking it ! The server is Apache on Windows. Delphi client works just fine so I'm pretty sure it's on VFP app side...
I just purchased your latest Client Tools - I will try with that version. If I won't figure out can you help me with it ? I will pay your support rate no problem...
Well the sample I posted you can try yourself - that checks for the client issue and that appears to be working just fine, so I'm pretty sure it's not hte client unless you're not sending the data correctly and you're actually getting an unrelated data - perhaps related to the embedded data you are sending.
That's why I ask - is it a server exception or a client error?
And yeah I can probably help if you can't resolve this...
+++ Rick ---
I just put latest version of wwClient and now I have a different problem... Code is fired but image is not transmitted into HTTP Server and I always get empty string as a response from server.